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