0

I'm just trying to simply copy down my formula to the last row, and recording the macro works, but gives me a hard coded row number:

Range("F2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-5]=RC[-4],""PASS"", ""FAIL"")"
Selection.AutoFill Destination:=Range("F2:F2502")

I've seen a few submissions who use lastrow or filldown instead of autofill which supposedly solves this problem, but I haven't been able to get it to work in my own situation.

The formula is =IF(A2=B2,"PASS","FAIL")

Any help is greatly appreciated.

  • see the dup as to finding the last row. then you would simply: `ActiveSheet.Range("F2:F" & LastRowVariable).FormulaR1C1 = "=IF(RC[-5]=RC[-4],""PASS"", ""FAIL"")"` no need for autofill or fill down. – Scott Craner Sep 11 '20 at 14:37
  • Looks great, except am I having to set a variable? I'm getting a runtime error 1004. Sorry, I'm not very good at this stuff. – evenyougreg Sep 11 '20 at 15:01
  • yes, use the link to the duplicate to get the last row in the variable. – Scott Craner Sep 11 '20 at 15:03

0 Answers0