I am using vlookup, after finding it with lookup i am using autofill. In macro after the autofill code it finds the range and autofills it. But in terms of code's robustness it is not usefull because the range it finds sticks to the code. Basically,
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-5],Sheet1!C[-5]:C[4],7,FALSE)"
Range("F2").Select
Selection.AutoFill Destination:=Range("F2:F502")
Range("F2:F502").Select
is the original code, i just want to do Range("F2: last data")
Thanks in advance
Edit: Solved.
Dim LastRow As Long
LastRow = Cells(Rows.Count, "F").End(xlUp).Row
Range("F2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-5],Sheet1!C[-5]:C[4],7,FALSE)"
Range("F2").Select
Selection.AutoFill Destination:=Range("F2", Cells(LastRow, 6))
I was trying to simplify the code but I guess I need to put this before every VLOOKUP