Reputation: 123
I'm trying to put this =IF(D49>0,D49-D50-D51+D52+D53,)
into a cell D54
by using macro.
My code is as follow
Range("D54").FormulaR1C1 = "=IF(D52>0,D49-D50-D51+D52+D53,)"
But when I run the macro.
Cell D54
gets this =IF('D52'>0,'D49'-'D50'-'D51'+'D52'+'D53',)
instead.
Excel adds quotation marks to each dells in the formula, render the formula useless. How can I get macro to into formula as formula?
Upvotes: 0
Views: 7026
Reputation: 58
I think you are having issues because you are using the R1C1 formula property for your range, yet you are using classical cell references in your formula. You should be using the Range("D54").Formula
property. So your code would look like:
Range("D54").Formula = "=IF(D52>0,D49-D50-D51+D52+D53,)"
Upvotes: 3
Reputation: 279
You could just use Range("D54").Value = "=IF(D52>0,D49-D50-D51+D52+D53,)"
I have used that method before and hand good results with it.
Upvotes: 0