【发布时间】:2017-05-18 02:54:27
【问题描述】:
我正在为 VBA 宏的语法而苦苦挣扎。试图从工作表 1 的工作表 2 列表中创建一个选择,它给了我运行时错误“1004”:应用程序定义的或对象定义的错误。
Sub Macro1()
Sheets("Sheet1").Select
Sheets("Sheet1").Range("G3").Select
With Selection.Validation
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="Sheet2!$A$1:$A$14"
.IgnoreBlank = True
.InCellDropdown = True
End With
End Sub
请帮助我了解我收到此错误的原因以及如何解决它?
【问题讨论】:
-
选择在活动表中,更改为您的 with 语句中的完整引用范围。视情况而定,您首先需要在添加之前删除验证