jeudi 7 novembre 2019

VBA If Statement Formula in a Loop and Range Function to Get Cell Value

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"")"

Aucun commentaire:

Enregistrer un commentaire