Autofill from Activecell to Lastrow

rhys_ack

New Member
Joined
Nov 5, 2012
Messages
6
Hi All,

My first post to the forum. Usually I find I am able to solve any problems I have by browsing historic posts and amending solutions to suit my needs however this one has me stumped.

I have a worksheet with four columns (A,B,C & D) which is tens of thousands of rows long and grows each day. New information is added to columns A, B and C each morning and D is updated at the end of the day. I am trying to fill column D using a formula entered in to the first blank cell in column D and autofilling down until level with the last cell containing data in column A/B/C (all will be the same). This is part of a larger macro formatting a report and trying to move information across. I can select the start cell and enter the formula but cannot get the autofill part to work.

I have tried several solutions but the code below is what I have at the moment;

Code:
Dim LastRow As Long

LastRow = Range("C" & Rows.Count).End(xlUp).Row
Selection.AutoFill Destination:=(ActiveCell.Address & ":D" & LastRow)

Which gives the error "Run-time error '1004': AutoFill methodof range class failed."

As I said I've tried a number of things none of which worked and this is simply the most recent attempt. There may well be a completely different approach that works better.

Any help will be greatly appreciated,

Rhys
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi All,

My first post to the forum. Usually I find I am able to solve any problems I have by browsing historic posts and amending solutions to suit my needs however this one has me stumped.

I have a worksheet with four columns (A,B,C & D) which is tens of thousands of rows long and grows each day. New information is added to columns A, B and C each morning and D is updated at the end of the day. I am trying to fill column D using a formula entered in to the first blank cell in column D and autofilling down until level with the last cell containing data in column A/B/C (all will be the same). This is part of a larger macro formatting a report and trying to move information across. I can select the start cell and enter the formula but cannot get the autofill part to work.

I have tried several solutions but the code below is what I have at the moment;

Code:
Dim LastRow As Long

LastRow = Range("C" & Rows.Count).End(xlUp).Row
Selection.AutoFill Destination:=(ActiveCell.Address & ":D" & LastRow)

Which gives the error "Run-time error '1004': AutoFill methodof range class failed."

As I said I've tried a number of things none of which worked and this is simply the most recent attempt. There may well be a completely different approach that works better.

Any help will be greatly appreciated,

Rhys

After the data is updated,You can simply highlight the first cell with the formula (Let's say D2 is the first cell after the header) and after selecting D2,Double click on the small black square in the right bottom corner of the selected cell and the formula will be automatically copied to the last cell containing data in Column A or B or C.
 
Upvote 0
Try

Code:
Dim LastRow As Long

LastRow = Range("C" & Rows.Count).End(xlUp).Row
ActiveCell.AutoFill Destination:=Range(ActiveCell.Address & ":D" & LastRow)
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,399
Latest member
alchavar

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