VBA: Copy to bottom of existing data

cmhoz

Active Member
Joined
Aug 20, 2006
Messages
268
I know this has been answered before - I even know I wrote it down - but now I just can't find it!

I have a list of data that grows. Next to the list I have some formulas that need to be copied down to match the growing list of data.

How do I say "copy to bottom of existing data" in VBA?

Thanks!
 

Trebor76

Well-known Member
Joined
Jul 23, 2007
Messages
4,490
cmhoz,

The following will find the last row in Column A (change as required) which contains data:

Code:
Sub LastRow()

Dim lngLastRow As Long

lngLastRow = Cells(Rows.Count, "A").End(xlUp).Row

End Sub
HTH

Robert
 

Blade Hunter

Well-known Member
Joined
Mar 13, 2008
Messages
3,147
Code:
    Range("B1").AutoFill Destination:=Range("B1:B" & Cells(Rows.Count, "A").End(xlUp).Row)
Substitute B for the column you want the formula in, Substitute A for where you can guarantee data to the end and substitute the 1 for whatever row your repetative formula first appears in.

Cheers

Dan
 

O177812

New Member
Joined
Apr 16, 2015
Messages
41
How would I use this with a range of cells? "B3:AQ3"?
 

Blade Hunter

Well-known Member
Joined
Mar 13, 2008
Messages
3,147
Perhaps this??

Code:
Range("B3:AQ3").AutoFill Destination:=Range("B3:AQ" & Cells(Rows.Count, "A").End(xlUp).Row)
 

O177812

New Member
Joined
Apr 16, 2015
Messages
41
Hi Blade, Thanks for your help.

I have one more question.

I have created this formula that selects the last row with data in Column B

Range("B" & Rows.Count).End(xlUp).Select
Range(Selection, Selection.End(xlToRight)).Select

Once this is selected I need to copy it down to the last row that contains data in Column A

Thanks for your help.
 

Forum statistics

Threads
1,085,884
Messages
5,386,553
Members
402,006
Latest member
stringer47

Some videos you may like

This Week's Hot Topics

Top