所以,我打开一个新的Excel工作表只是通过VBA了解更多关于数据验证的创建和我进入下面的代码是从的Microsoft Developer Network网站的例子:VBA Validation.Add方法失败
With Range("$E$5").Validation
.Add Type:=xlValidateWholeNumber, _
AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:="5", Formula2:="10"
.InputTitle = "Integers"
.ErrorTitle = "Integers"
.InputMessage = "Enter an integer from five to ten"
.ErrorMessage = "You must enter a number from five to ten"
End With
我得到了下面的错误,当我执行的代码:
运行时错误 '-2147417848(80010108)':
Method对象的'添加 '验证' 失败
我到处搜寻,但没有发现对这个问题什么...
您是否已经在E5设置中进行了验证?如果是这样,请尝试在添加新文件之前用'.Delete'删除它。 –