I am trying to assign If formula to certain cell every 16th row. Formula needs to compare values of cells in J, K and L columns and gives Pass or Fail Result.
I am having issues making this If formula work in a loop. Please Help! My Code is below.
First I am getting compile error saying " Expected end of statement"
Second, is there any other way to make these work? I need same formula applied to Cell M5 to M789 at every 16th cell.
For a = 5 To 789 Step 16
Range("M" & a).FormulaR1C1 = "=IF(Range("J" & a)>= Range("K" & a),IF(Range("J" & a))<= Range("L" & a),""PASS"", ""FAIL""),""FAIL"")"
.Formulainstead of.FormulaR1C1. 2) Don't useRangewithin a formula - that's mixing VBA into regular worksheet formulas. You can't useRange(J5)in a worksheet - justJ5."J","K", and"L"- drop theRangecalls from the formula part.J,KandLcolumn values going to change? Otherwise you are doing unnecessary calculations.