0

I'm looking to apply a nested IF formula to the end of a dynamic range Column "B". The formula runs off of values from column "F" accordingly. Following a previous AutoFill code example, I now get [Compile Error: Expected End of Statement]

Range("A2").Select
ActiveCell.FormulaR1C1 = "=IF(F2>=750000, "Major", IF(F2>20000, "SAT", "Micro "))"
Range("E2").Select
Selection.AutoFill Destination:=Range("A2:A" & Range("B" & Rows.Count).End(xlUp).Row)
Range(Selection, Selection.End(xlDown)).Select

I'm also thinking this is the incorrect way to do it because I need the "F2" cell reference to be updated as the formula goes down the line.

How can I correct my code in order to achieve this?

Kato
  • 41
  • 1
  • 10
  • 2
    `Range("A2:A" & Range("B" & Rows.Count).End(xlUp).Row).Formula = "=IF(F2>=750000, ""Major"", IF(F2>20000, ""SAT"", ""Micro ""))"` – BigBen Jan 26 '21 at 19:30
  • 2
    The main error is that you need to double up the quotes. But you don't need to `AutoFill` here at all, nor `Select`. Plus use `.Formula`, not `.FormulaR1C1`. – BigBen Jan 26 '21 at 19:31
  • 1
    @BigBen this worked exactly as I wanted! Thanks for the fix and explanation. – Kato Jan 26 '21 at 21:37

0 Answers0