2
好吧,基本上我想要做的是为特定的单元格设置数据验证列表。 这个列表应该包含我指定的一定范围的单元格PLUS添加一个字符串值。 我有一个对话框,询问用户的名称,然后我需要列表显示包含“其他”的单元格的设置范围,&名称添加到它。Excel VBA:命名范围+字符串值作为验证列表?
name = "Test"
With Worksheets("Tijdsregistratie").Cells(aangepasteRij, 4).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=nameRange, name"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
就像上面的代码(显然公式不起作用)。 有没有办法使用特定的公式来做到这一点,或者我将不得不找到另一种方法来完成这个任务?
这可能有一些帮助:http://stackoverflow.com/questions/4783019/can-i-use-vba-function-to-return-a-dynamic-list-of-acceptable-values-into- Excel中/ 4797514#4797514 – jtolle 2011-06-09 23:10:20