I have made this very simple loop to apply a formula to all cells in a range:
For Each cell In Range("G5:G500")
cell.Offset(0, 7).FormulaR1C1 = "=IF(Len(RC[-4]>0),(RC[-2])/(RC[-4]),"")"
Next
It gives "application-defined or object-defined error" for the line
cell.Offset(0, 7).FormulaR1C1 = "=IF(Len(RC[-4]>0),(RC[-2])/(RC[-4]),"")"
I can't work out where i'm going wrong here. I've tried:
- Various different formats of R1C1 (e.g RC[1] or R[]C[1])
- using formula instead of R1C1 but then I can't refer to cells geometrically
- I'm pretty sure all my bracketing is correct
very baffled and would really appreciate a tip or hint on this!