Macro copy formulas down a specific range

spill-the-beans

Board Regular
Joined
Feb 7, 2013
Messages
52
Hi all,

In my sheet called Data, cells Y2:BF2 contain formulas.

At the moment, I've been manually dragging the formulas to copy them down all my data. I only need to copy them down as far as the last cell with data in column V2, but where this last row is will keep changing.

I was wondering if there was a way of creating a macro to find out where the last cell was, then copy the formulas from Y2:BF2 down every row, stopping at that last cell?
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
You can try this

Save your sheet/workbook before trying.

Right click sheet name - View code
Copy and paste code below

Put cursor at beginning cell in col Y and run macro

Code:
Sub filldown()

    
    Dim aRng As Range
    Set aRng = Selection.CurrentRegion
        

aRng.AutoFill Destination:=Range(aRng, Cells(Cells(Rows.Count, "V").End(xlUp).Row, "Y"))

End Sub
 
Upvote 0
So I tried to run the code and it comes up with a box saying "Run time error 1004, AutoFill method of Range class failed", then highlights the last line of code before End Sub. . .
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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