Reputation: 999
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"
Upvotes: 1
Views: 1377
Reputation: 181
You need to use single quotes for the string otherwise the string ends and will throw an error but there may be something else going on. What is your exact error?
Upvotes: -1
Reputation: 1163
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
.
Upvotes: 6