Half the code in my script is giving an error

Viewed 35
For i = 2 To 50
ws.Range("K" & i).FormulaLocal = "=if(countif($C$2:C" & i & ";C" & i & ")=1;row();"")"
Next i

ws.Range("K" & i).FormulaLocal = "=if(countif($C$2:C" & i & ";C" & i & ")=1;row();"")

I am getting error on this line. Where am I going wrong?

1 Answers

you need to double the quotation marks within the string (at the end):

ws.Range("K" & i).FormulaLocal = "=if(countif($C$2:C" & i & ";C" & i & ")=1;row();"""")"
Related