Hi, I keep getting "object defined error" when I run my macro.
Sub data()
Sheets("Data out of range").Activate
Cells(5, 5).FormulaR1C1 = "=IF(RC1<'Expt Plan'!R27C16,IF(OR(pH!R[-2]C3>='Expt Plan'!R27C15+0.5,pH!R[-2]C3<='Expt Plan'!R27C15-0.5),RC1-R[-1]C1,""),"")"
End Sub
If I paste the formula =if(RC1<'Expt Plan'!.... into a cell in Excel, the formula works.
If I run the code without the formula, eg,
Sub data()
Sheets("Data out of range").Activate
Cells(5, 5).FormulaR1C1 = "hello" 
End Sub
then the macro works.

Why don't they work together??