0

我有一个名为“myList”的命名范围,定义为 Sheet1 的第 1 到 200 行。共有 20 列,前 8 列是有关员工的信息,后 12 列是 0 或 1,用于包含每个月的员工。

现在,我想创建一个下拉菜单,如果我的命名范围的第 9-20 列中至少有一个 1,它将显示员工的姓名。

目前,我使用以下公式作为数据验证:=INDEX(myList,,1)它会显示 myLast 中的每个名称,无论第 9-20 列是否有 1。

如何更改此设置,以便在创建下拉菜单的数据验证中显示的唯一名称是 myList 的第 1 列上的名称,其中 myList 的第 9-20 列的相应 SUM() >= 1?

4

2 回答 2

1

Here is a workabout to your question :
Create a column SUM after the last column and calculate the sum of each row. lets say column V of your datasheet
then use the following array formula to filter the names whose sum is >=1

lets say you put this formula in X1 and drag and fill down until the last row.

=IFERROR(INDEX($A$2:$V$31;SMALL(IF($V$2:$V$31>=1;ROW($V$2:$V$31));ROW(1:1))-1;1);"")


this is an array formula, so press ctrl+shift+enter to calculate the formula



then in Z1 create your dropdown list based on the filtered names in column X.
please replace the 31 with 201 because you will have 200 rows plus one row of headings, if it is the case. I used 30 items in my example sheet.
tell me if it works.
***UPDATED***
sorry there was a mistake in the formula, it is now corrected. Here is the corrected formula. It now works fine. I also changed the download link.

于 2014-12-03T22:07:59.650 回答
0

您可以在不直接引用一组工作表单元格的情况下编写DV列表:

Sub NotUsingCells()
    Dim StringOfNames As String
    StringOfNames = "Larry,Moe,Curley"
    With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:=StringOfNames
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = ""
        .ErrorTitle = ""
        .InputMessage = ""
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = True
    End With
End Sub

在您的情况下,您将逐行处理myList ,通过连接符合您条件的名称来构建StringOfNames 。

于 2014-12-03T20:49:31.787 回答