I am trying to do an AutoFill in Excel where I can make my macro:
B40
), and remember. A1
. A1
's formula to the row that was found in step 1 (which would be A40
) so as to perform an autofill the formula. I am pretty noobish at VBA so would really appreciate some help.
This should do what you need.
' Get last row with data in column B...
Dim intLastRow As Long
intLastRow = Cells(Rows.Count, "B").End(xlUp).Row
' Fill column A down to this row...
Range("A1:A" & intLastRow).FillDown
You don't even require a Range.FillDown or Range.AutoFill method in this case.
With ActiveSheet
.Cells(1, 1).Resize(.Cells(Rows.Count, 2).End(xlUp).Row, 1) = .Cells(1, 1).Formula
End With
Just start with the top-left cell and use the Range.Resize property to expand it to the desired dimensions and transfer the formula.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.