公式适用于Excel,但不适用于vba(Formula works in excel but not in vba)
下面的公式适用于单元格,但是当我尝试在VBA中使用它时,它会给出语法错误。 为什么它是和解决方案是什么? 谢谢。
ThisWorkbook.Sheets("Sheet2").Cells(Lastrow + 1, 9).Formula = "=(SUMIFS(Sheet1!$B:$B,Sheet1!$O:$O,">0")/SUM(Sheet1!$B1:$B1000))*100"the below formula works in a cell, but when I try to use it in VBA it gives syntax error. Why is it and what is the solution?. Thanks.
ThisWorkbook.Sheets("Sheet2").Cells(Lastrow + 1, 9).Formula = "=(SUMIFS(Sheet1!$B:$B,Sheet1!$O:$O,">0")/SUM(Sheet1!$B1:$B1000))*100"最满意答案
问题是">0"在String使用引号需要执行以下操作:
"">0""用双引号VBA可以理解它在String一个String 。 而不是" String >0结束"一些代码和"一个新的String的开始。
The problem is with ">0" to use quotations inside a String you need to do the following:
"">0"" with double quotations VBA understands its a String inside the String. instead of the end " of the String >0 some code and " the start of a new String.
更多推荐
发布评论