范围验证无效的过程调用

时间:2014-06-13 11:37:11

标签: validation excel-vba vba excel

我有一个会话,我尝试将列表类型验证放到不连续的范围内。列表范围来自另一个名为(Range5)的工作表。

With Range("storeRanges").Cells.Validation

Dim ValidationList As Variant
ValidationList = Sheet2.Range("Range5")

   .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
    Operator:=xlEqual, Formula1:=Join(ValidationList, ",")

End With

我在 .add行上收到“无效的程序调用或参数”。谢谢你的帮助!

1 个答案:

答案 0 :(得分:0)

Soo,解决方案是:

With Range("storeRanges").Cells.Validation

Dim ValidationList As Variant
ValidationList = Sheet2.Range("Range5")

.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Operator:=xlEqual, Formula1:="=Range5"

End With

请注意.DeleteFormula1:="=Range5"