1
Sub Gang()

Dim formula_1 As String

formula_1 = "=IF(A1<>"",1,0)"
Range("A2").Formula = formula_1

End Sub

Very simple as you can see but its causing me an issue on another macro im working on, clearly I am doing something wrong but whenever I run this macro I get the error "Run-time Error '1004'"

So please help me understand how to correctly insert an IF statement using .Formula

I was just expecting to see the IF statement in cell A2

Scott Craner
  • 148,073
  • 10
  • 49
  • 81
  • 4
    `formula_1 = "=IF(A1<>"""",1,0)"` The quotes in the formula were breaking the string, you need to double them up. – Warcupine Dec 27 '22 at 14:07

0 Answers0