adding a formula with a macro

Copper Contributor

I am adding a formula to a cell through a macro.  If I enter the formula manually it works perfectly but when I use the macro to add the formula it leaves the formula text in the cell and not the result of the formula.  Here is the code in the macro:

Range("H2").Select
ActiveCell.FormulaR1C1 = "=IF(G2="""",Today()-A2,G2-A2"

1 Reply

@Kraway 

This works in my sample file.

Range("H2").Formula = "=IF(G2="""",Today()-A2,G2-A2)"