Link to home
Start Free TrialLog in
Avatar of Ruchi_Sas

asked on

how to drag vlookup in vba for all the cells down with dynamic range

how to drag vlookup in vba for all the cells down
I have written

     Cells(4, Newcolumn).Formula = Application.WorksheetFunction.VLookup(Range("A4"), Sheets("Basic_Data").Range("C2:J7129"), 8, False)

Selection.AutoFill Destination:=Cells(newrange & ":" & r & "7129")
 Range(newrange & ":" & r & "7129").Select

but this is copying only values not formula. I need to use dynamic range
Avatar of FernandoFernandes
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
here is another 2 ways to find the last rows
Sub Macro1()
Dim i As Integer
    i = ActiveSheet.UsedRange.Rows.Count
    MsgBox i
End Sub

Sub macro2()
Dim i As Integer
    i = Range("C65536").End(xlUp).Row
    MsgBox i

End Sub

Open in new window