Reputation: 35
In the following piece of VBA code, how do I replace the reference to the worksheet 'ContolPage' with the variable 'cPage'?
ActiveCell.FormulaR1C1 = "=IF(RC[5]="""","""",ControlPage!R[-13]C[-2])"
Thanks
Upvotes: 1
Views: 281
Reputation: 152450
You need to remove any vba variable from the quotes and concatenate with &
:
ActiveCell.FormulaR1C1 = "=IF(RC[5]="""","""",'" & cPage & "'!R[-13]C[-2])"
Upvotes: 1