Forum

How to use double q...
 
Notifications
Clear all

How to use double quotes inside a string when writing a formula to cells

3 Posts
2 Users
0 Reactions
1,814 Views
(@parth-thaker)
Posts: 2
New Member
Topic starter
 

Hi,
I am trying to add VBA for inserting formula in a range, but compile error is coming. Can someone please help on this.
i have imported the macro in personal.xlsb file hence i am using macro free work book.

 
Posted : 31/07/2020 6:22 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi,

You need to double up on the double quotes inside the string, otherwise it looks to VBA like you are ending the string because there's a single " in the middle of the string.

Range("S2:S" & lastRow).Formula = " =IF(OR(L2=30003322, L2=30004056, L2=30009486, L2=30013917, B2=""CHP Hydra""), ""CHP-MMD"", IF(OR(L2=30004254, L2=30007286, Q2=""ABS""), ""ABS"", ""CHP-Oprn""))"

Regards

Phil

 
Posted : 31/07/2020 9:18 am
(@parth-thaker)
Posts: 2
New Member
Topic starter
 

Thank you very much sir for quick reply. The answer served my purpose.

 
Posted : 01/08/2020 3:44 am
Share: