Run Time Error on Active formula in Excel Macro code
Run Time Error on Active formula in Excel Macro code I want to use the value of cell A5 of Sheet 2 to my active formula in macro in Sheet 1. However, I'm getting an Error 1004 (application defined or object defined error). If using a static value, for instance 100, instead of 'Sheet 2'!A5 , it is working. 'Sheet 2'!A5 Below is my code: ActiveCell.FormulaR1C1 = "=if('Sheet 2'!RC>'Sheet 2'!A5,""PASS"", ""FAIL"")" 1 Answer 1 You cannot mix-and-match xlA1 cell references with xlR1C1 cell references. A5 is R5C1 in xlR1C1 syntax. ActiveCell.FormulaR1C1 = "=if('Sheet 2'!RC>'Sheet 2'!R5C1,""PASS"", ""FAIL"")" Now in this formula, the RC is a relative row/relative column reference to the same cell on 'Sheet 2' that the active cell on the active ...