I am playing around with VBA in Excel, and cant for the life of me figure out why this error is popping up.
The following code works:
Cells(1, 1) = " =if(counta( " & aLoc & "Subbies'!$A$2:$A$20>0 ""YES"", ""NO"" "
The following code doesnt work:
Cells(1, 1) = "=if(counta( " & aLoc & "Subbies'!$A$2:$A$20>0 ""YES"", ""NO"" "
So Just by removing the space to make the line of code insert a formula rather than a string causes the compiler to through up error 1004.
In other lines ive used itll insert a formula no problem, but concatenating text with a local variable seems to throw this up. Any ideas?

)and so excel cannot put it in as it is a bad formula.Cells(1, 1) = "=if(counta('" & aLoc & "Subbies'!$A$2:$A$20)>0, ""YES"", ""NO"" )"