excel 用vb插入下拉列表公式
我要用vb在指定单元格插入下拉列表,但输入公式的时候遇到问题,如下面代码是正确的!WithSheets(i).Cells(k,j).Validation.Delete.A...
我要用vb在指定单元格插入下拉列表,但输入公式的时候遇到问题,如下面代码是正确的!
With Sheets(i).Cells(k, j).Validation .Delete .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, _ Formula1:="1+1" .IgnoreBlank = True .InCellDropdown = True .InputTitle = "" .ErrorTitle = "" .InputMessage = "" .ErrorMessage = "" .IMEMode = xlIMEModeNoControl .ShowInput = True .ShowError = FalseEnd With
但如果把其中第四行“Formula1:="1+1" ” 中的1+1变为公式 =1+1 就会报错,代码如下:
With Sheets(i).Cells(k, j).Validation .Delete .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, _ Formula1:="=1+1" .IgnoreBlank = True .InCellDropdown = True .InputTitle = "" .ErrorTitle = "" .InputMessage = "" .ErrorMessage = "" .IMEMode = xlIMEModeNoControl .ShowInput = True .ShowError = FalseEnd With
这样执行就会报错:“运行时错误‘1004’ ,应用程序定义或对象定义错误”。就多一个等号!
请问我应该怎样做才可以插入这个公式?(当然不会是1+1这么简单了) 展开
With Sheets(i).Cells(k, j).Validation .Delete .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, _ Formula1:="1+1" .IgnoreBlank = True .InCellDropdown = True .InputTitle = "" .ErrorTitle = "" .InputMessage = "" .ErrorMessage = "" .IMEMode = xlIMEModeNoControl .ShowInput = True .ShowError = FalseEnd With
但如果把其中第四行“Formula1:="1+1" ” 中的1+1变为公式 =1+1 就会报错,代码如下:
With Sheets(i).Cells(k, j).Validation .Delete .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, _ Formula1:="=1+1" .IgnoreBlank = True .InCellDropdown = True .InputTitle = "" .ErrorTitle = "" .InputMessage = "" .ErrorMessage = "" .IMEMode = xlIMEModeNoControl .ShowInput = True .ShowError = FalseEnd With
这样执行就会报错:“运行时错误‘1004’ ,应用程序定义或对象定义错误”。就多一个等号!
请问我应该怎样做才可以插入这个公式?(当然不会是1+1这么简单了) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |