如何清除动态数据验证错误

时间:2019-07-03 09:43:58

标签: vba

我的代码将列表中的验证动态分配给特定范围的数据。但是,同样会发生错误。列表的所有元素都分配给row1,但是减去列表顶部元素的所有元素都分配给row2,类似地,对于row3,减去列表顶部两个元素的所有元素都被分配,依此类推。请查看图片以更好地了解我的问题

With sht.Range("C2:C" & LastRow1).Validation 'LastRow1 is the last row till which validations have to be assigned
    .delete
    .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
    Operator:=xlBetween, Formula1:="=DropDown!C2:C" & LastRowS 'LastRowS is the last row of the list from which validations will be assigned
    .IgnoreBlank = True
    .InCellDropdown = True
    .InputTitle = ""
    .ErrorTitle = ""
    .InputMessage = ""
    .ErrorMessage = "Value not present in drop down."
    .ShowInput = True
    .ShowError = True
End With

LIST ROW1 ROW2

0 个答案:

没有答案