Avinash
Avinash

Reputation: 21

Passing a Variable in ActiveCell.FormualR1C1

Hi I am trying to pass a variable inside the below line but apparently its the wrong way. Can someone please guide me in the right direction please :)

Dim variable as string
variable = "something"

ActiveCell.FormulaR1C1 = "=if([@Column1]=" & variable & ", TRUE, FALSE)"

Upvotes: 1

Views: 42

Answers (1)

Tim Williams
Tim Williams

Reputation: 166351

Try:

Dim variable as string
variable = "something"

ActiveCell.Formula = "=if([@Column1]=""" & variable & """, TRUE, FALSE)"

You need to add the quotes around your variable (and embedded quotes need to be doubled-up to escape them)

Upvotes: 1

Related Questions