Excel VBA – 手动input数据validation单元格中的数据

我有工作表,其中有各种validation列表,但是对于所有这些列表我需要有用户自己在单元格中的条目的选项。

我知道你可以取消选中框,但是因为我的工作表经常重新生成我需要实现这个编程。 任何人有任何想法如何做到这一点? 这里是我创build下拉列表的代码:

For u = 1 To SpecDependencies.count SpecDepList = SpecDepList & "," & SpecDependencies(u) & " - " & SpecDepDate(u) Next With CRC.Cells(ECURowInCRC, 8).Validation .Delete .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _ xlBetween, Formula1:=SpecDepList .IgnoreBlank = True .InCellDropdown = True .InputMessage = "View Spec Dependancies" '.ErrorMessage = "No value selected" .ShowInput = True '.ShowError = True End With End If SpecDepList = "" Set SpecDependencies = New Collection Set SpecDepDate = New Collection 

你几乎已经在你发布的代码中获得了它,只需将.ShowError改为false,用户可以input任何内容而不会被警告

 For u = 1 To SpecDependencies.count SpecDepList = SpecDepList & "," & SpecDependencies(u) & " - " & SpecDepDate(u) Next With CRC.Cells(ECURowInCRC, 8).Validation .Delete .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _ xlBetween, Formula1:=SpecDepList .IgnoreBlank = True .InCellDropdown = True .InputMessage = "View Spec Dependancies" '.ErrorMessage = "No value selected" .ShowInput = True .ShowError = False End With End If SpecDepList = "" Set SpecDependencies = New Collection Set SpecDepDate = New Collection