Find end of column and paste formula in range

  • Thread starter Thread starter MGS
  • Start date Start date
M

MGS

I am extracting data from a database into Excel. My colums are constant, but
number of rows vary.

I need to copy a formula from AC2 down to the last row in that column.

Thanks for the help!
 
Try this small macro:

Sub CopyFormula()
Dim nLastRow As Long, destynation As String
Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.Count + r.Row - 1
destynation = "AC3:AC" & nLastRow
Range("AC2").Copy Range(destynation)
End Sub
 
Will the formula already be in AC2?

Is there any adjacent column that will extend to last row?

I will assume there is a formula and use column AB to determine last row.

Sub Auto_Fill()
Dim Lrow As Long
With ActiveSheet
Lrow = .Range("AB" & Rows.Count).End(xlUp).Row
.Range("AC2:AC" & Lrow).FillDown
End With
End Sub


Gord Dibben MS Excel MVP
 
Back
Top