Archive of Mr Excel Message Board

Back to Excel VBA archive index
Back to archive home

Autofill a Column to last row of data

Posted by Maud on July 25, 2000 4:13 AM
I'm looking for a code that will do the following

I paste data from another workbook to the workbook in which want the macro to work.
The Pasted data will vary in size, so that the Row length will change - I have a formula alongside that changes the format.
What I want it to do is Autofill the formula to the last row of the pasted data.

EG copied data A2:D410
Formula in Column E
The formula in Column E will autofill down to E410

Is this possible?


Check out our Excel VBA Resources

Re: Dim switch on -Help!

Posted by Ivan Moala on July 26, 0100 2:28 AM

Hi Maud
I think the code in your situation should be;

Sub Q2AutoFillRange()
Dim AutoFillRg As Range

Set AutoFillRg = Range(ActiveCell, ActiveCell.End(xlDown))
Selection.Offset(0, 1).AutoFill Destination:=Range(AutoFillRg.Offset(0, 1).Address)

End Sub

Try this and let me know.


Re: Autofill a Column to last row of data

Posted by JAF on July 25, 0100 5:00 AM
This is one that I had a problem with a while back. The ever helpful Ivan posted a reply which can be found at: 1904c.html

This worked for what I needed.


Dim switch on -Help!

Posted by Maud on July 25, 0100 6:36 AM

I think my brain has gone to the setting "Dim" because I looked at the code and tried to use it but it wouldn't work.

Can someone give me instructions on how to use or set up.

Ps Cheers for the site JAF.


Posted by Maud on July 28, 0100 8:13 AM

Thanks Ivan!!

Re: Autofill a Column to last row of data

Posted by Mike on July 25, 0100 4:07 PM
I tried to use the code and could not get it to work ..... I need start at J2 and autofill to last cell in the column ...

Best regards,

This archive is from the original message board at
All contents © 1998-2004
Visit our online store to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.