I want to select the dynamic cell and autofill it till the last row

Viewed 106

the value is in cell C and lastrow2 and want to autofill till lastrow3

Range("C" & lastrow2).Select
Selection.AutoFill Destination:=Range(.Cells(lastrow2, 3), .Cells(lastrow3, 3)).FillDown
1 Answers

Rather than .Select and then Autofill, you can populate the entire range in one go. Is this what you are trying?

ws.Range(ws.Cells(lastrow2, 3), ws.Cells(lastrow3, 3)).Formula = _
ws.Cells(lastrow2, 3).Formula

Where ws is your relevant sheet. For example

Dim ws As Worksheet
Set ws = Sheet1
Related