I am trying to get my VB script to enter an Excel formula into a cell. Unfortunately I had no luck so far.
Sheets("ABC").Select
Range("B2").Value = "=IF(Mat_Location!F2=0;"";Mat_Location!F2)"
After some googling and searching on this site I figured it would be because of the quotation marks and so I tried changing the quotation marks to double quotation marks.
Sheets("ABC").Select
Range("B2").Value = "=IF(Mat_Location!F2=0;"""";Mat_Location!F2)"
That also didn't help.
Any help is appreciated. Thanks in advance.
Replace your multiple
"
withChr(34)
, it's easier to debug it this way.Also, there's no need to
Select
the sheet first.Note: it seems your Excel's regional settings is having
;
as a delimeter inside the formula. The default settings is,
, so for my Excel setting (maybe also yours) it might be: