简体   繁体   English

使用VBA在由字符串和整数组成的Excel单元格中设置公式

[英]Set a formula in an Excel Cell composed by a string and a integer using VBA

I am getting an error on VBA when doing the following: 执行以下操作时,VBA出现错误:

filterTotalRow = orderCount + 5
Cells(138, 5).Value = "=SUBTOTAL(3;E3:E" + filterTotalRow + ")"

But I get an error. 但是我得到一个错误。 What is wrong? 怎么了? How can I insert a formula composed by a string and a number, as described? 如上所述,如何插入由字符串和数字组成的公式?

You are using the wrong symbol for concatenation. 您使用错误的符号进行串联。 You should use '&' instead of '+' 您应该使用“&”而不是“ +”

Cells(138, 5).Value = "=SUBTOTAL(3;E3:E" & filterTotalRow & ")"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM