Autofill / Filldown

SpaceCowboy

New Member
Joined
May 31, 2011
Messages
2
Hi,

I'm pretty new to VBA, learning little bits and using existing code to get me through situations over past year; I am however stumped at something I am currently trying to do and hope that some kind person here will know the answer.

I am trying to Auto Fill or Fill Down the contents of the currently active cell down to the next cell that has any data in it. For example I am in cell A1 which has data in it, cells A2-A14 are empty, cell A15 is not. I'm trying to copy the contents of A1 down thru A15. I managed to do it once but then I made a schoolboy error and closed the file before it was saved and I cant for the life of me work out how I did it. Any help would be greatly appreciated. I have the code and example spreadsheet if it helps.

Many thanks,
Moz
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Try

Code:
ActiveCell.AutoFill Destination:=Range(ActiveCell, ActiveCell.End(xlDown))
 
Upvote 0
Welcome to the Board.

There are several ways of achieving this, such as:

Range("A1").Copy Range(Range("A2"), Range("A2").End(xlDown).Offset(-1))
 
Upvote 0
Try

Code:
ActiveCell.AutoFill Destination:=Range(ActiveCell, ActiveCell.End(xlDown))

You sir, are an absolute star! I spent a whole day on this last Friday, I should have come here first. Still, all part of the learning curve I guess.

Very much appreciated.
 
Upvote 0
Code:
Sub AutoFilling()
    Dim rngLast As Range
    Set rngLast = Range("A2").End(xlDown).Offset(-1, 0)
    Range("A1").AutoFill Range("A1", rngLast)
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,558
Members
452,928
Latest member
101blockchains

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