Copy formula to last row

ai1094

Board Regular
Joined
Aug 23, 2018
Messages
92
Is there a simple VBA code that will auto fill my formula in the current cell to the last row containing data?
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
What cell is the formula in?
What column can we look in to see where the data ends?
 
Upvote 0
DynamicRange_Fill Down
Range("A2:A" & ActiveSheet.Range("B" & Rows.Count).End(xlUp).Row).Select
Selection.FillDown

Update "B" for the column with no blank lines.
 
Upvote 0
Does this macro do what you want...
Code:
Sub ExtendFormulaInCellA2()
  Dim LastRow As Long
  LastRow = Cells.Find("*", , xlValues, , xlRows, xlPrevious).Row
  Range("A3:A" & LastRow).Formula = Range("A2").Formula
End Sub
 
Upvote 0
This was excellent. Thank you!

Does this macro do what you want...
Code:
Sub ExtendFormulaInCellA2()
  Dim LastRow As Long
  LastRow = Cells.Find("*", , xlValues, , xlRows, xlPrevious).Row
  Range("A3:A" & LastRow).Formula = Range("A2").Formula
End Sub
 
Upvote 0
I have another sheet with formulas in Cell N83 from Column N all the way up into Column X. How can I autofill Columns N:X to the last row of data in Column A?
 
Upvote 0
I have another sheet with formulas in Cell N83 from Column N all the way up into Column X. How can I autofill Columns N:X to the last row of data in Column A?

With that sheet active, give this macro a try...
Code:
Sub ExtendFormulaInCellA2()
  Dim LastRow As Long
  LastRow = Cells(Rows.Count, "A").End(xlUp).Row
  Range("N84:X" & LastRow).Formula = Range("N83:X83").Formula
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,952
Messages
6,175,594
Members
452,656
Latest member
earth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top