3
我具有下面的VBA功能。這是建立在給定的細胞下拉使用範圍公式時丟失下拉值
Public Sub CORE_SetValidation(ByRef Rng As Range, ByVal Value As String)
With Rng.Validation
Call .Delete
If Value <> "" Then
Call .Add(Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:=Value)
.ErrorMessage = "Please select a value from drop-down list"
.ErrorTitle = "Value Error"
.IgnoreBlank = True
.InCellDropdown = True
.InputMessage = ""
.InputTitle = ""
.ShowInput = True
.ShowError = True
End If
End With
End Sub
當我用逗號分隔值值傳遞給這一點,所有的整個列
dictkeystring = "1,2,3,4,5,6,7,8,9"
CORE_SetValidation(Sourcews.Columns(AllocationSheet_Prj_COLUMN).EntireColumn, dictkeystring)
但是當我通過它的做工精細值使用範圍公式,它不工作。
dictkeystring = "=PrjList!A2:A6"
CORE_SetValidation(Sourcews.Columns(AllocationSheet_Prj_COLUMN).EntireColumn, dictkeystring)
問題是,對於每個單元我缺少一個值;在第一列中缺少一個VAL,第二單元失蹤2 VAL,第三失蹤3個值,......經過一番的地方,我丟失了所有的值,空下拉我得到
非常感謝,很好的解釋 – ManiMuthuPandi