copy / paste formula to last row

  • Thread starter Thread starter tnriverfish
  • Start date Start date
T

tnriverfish

I'm very green to programming in Visual Basic but this seems like a
perfect application from reading through some other threads.

My spreadsheet has separate formulas in AC1 through AN1 and I would
like to essencially drag that formulas down through the last row that
has any data in it.
The formulas would have to adjust like a regular drag down. Any help
would be appreciated.
 
one way:

Assume that the last row to have data in it will have data in column AB.

Then

Public Sub FillDown()
Range("AC1:AN1").AutoFill _
Destination:=Range("AC1:AN" & _
Range("AB" & Rows.Count).End(xlUp).Row), _
Type:=xlFillDefault
End Sub
 
That particular column will not but could I replace that with
different column reference that will in every row
 
Yes, if column A will have data in every row, change "AB" to "A"
 
tnriverfish said:
My spreadsheet has separate formulas in AC1 through AN1 and I would
like to essencially drag that formulas down through the last row that
has any data in it.
The formulas would have to adjust like a regular drag down. Any help
would be appreciated.

How about:
Sub sub1()
Dim irow99&, icol99%
ActiveSheet.UsedRange ' to get the last row, column
irow99 = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
icol99 = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Column
ActiveSheet.Range("AC1:AN1").Copy _
ActiveSheet.Range("AC1:AN1").Resize(irow99)
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top