VBA 将单元格值设置为包含“无效”的文本
VBA Set Cell value to text containing ' not working
我正在尝试获取一个宏来为我键入一堆公式。公式是这样的:
=COUNTIF('other_sheet'!A:A,"hello*")
用户可以指定A和other_sheet,所以我select单元格然后去
ActiveCell.Value = "=COUNTIF('" & othercell & "'!" & column & ":" & _
column & """,hello*"")"
但它一直给我这样的错误:
1004: Object Defined Error
我试过使用ActiveCell.Text
、ActiveCell.Formula
等,但它们都不起作用。
它需要是 ActiveCell.Formula
而 ",
是 Hello
旁边的错误方式。应该是:
ActiveCell.Formula= "=COUNTIF('" & othercell & "'!" & column _
& ":" & column & ",""hello*"")"
显然,您只能将正确、完整的答案放入单元格中。
即如果输出结果为 "=sum(A:A" 并且括号未闭合,则应用程序将抛出错误,就像您手动输入它一样。
我正在尝试获取一个宏来为我键入一堆公式。公式是这样的:
=COUNTIF('other_sheet'!A:A,"hello*")
用户可以指定A和other_sheet,所以我select单元格然后去
ActiveCell.Value = "=COUNTIF('" & othercell & "'!" & column & ":" & _
column & """,hello*"")"
但它一直给我这样的错误:
1004: Object Defined Error
我试过使用ActiveCell.Text
、ActiveCell.Formula
等,但它们都不起作用。
它需要是 ActiveCell.Formula
而 ",
是 Hello
旁边的错误方式。应该是:
ActiveCell.Formula= "=COUNTIF('" & othercell & "'!" & column _
& ":" & column & ",""hello*"")"
显然,您只能将正确、完整的答案放入单元格中。
即如果输出结果为 "=sum(A:A" 并且括号未闭合,则应用程序将抛出错误,就像您手动输入它一样。