公式适用于Excel,但不适用于vba(Formula works in excel but not in vba)

编程入门 行业动态 更新时间:2024-10-17 23:32:14
公式适用于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.

更多推荐

本文发布于:2023-08-06 23:26:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1456687.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:适用于   但不   公式   works   excel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!