Macro to Autofill column

dmcclel

New Member
Joined
Jul 28, 2011
Messages
8
I have set up a macro to help with a file I work on weekly. I get a new import each week and the # of lines in the file differ from week to week. I do not know how to set it up so it autofills my column (D) to the last cell with info in the previous column (C). The way I have it set up just autofills to the range in my original file. How do I set this up so it only autofills to the last full cell in column C.

COL A COL B COL C COL D
XXXX XXXX XXXX XXXX
XXXX XXXX XXXX
XXXX XXXX XXXX
XXXX XXXX XXXX
XXXX XXXX XXXX
XXXX

This is the code that I have. How can I fix this?

Selection.AutoFill Destination:=Range("D2:D395")
Range("D2:D395").Select

Thanks for any help!!
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
try
Code:
range("D2",cells(rows.count,"C").end(xlup).offset(,1)).formular1c1=range("D2").formular1c1
 
Upvote 0
Try

Code:
LR = Range("C" & Rows.Count).End(xlUp).Row
Range("D2").AutoFill Destination:=Range("D2:D" & LR)
 
Upvote 0
try
Code:
range("D2",cells(rows.count,"C").end(xlup).offset(,1)).formular1c1=range("D2").formular1c1


I tried this and it still fills to the last ROW with information. There is alot of junk info in column A and B and the rest of my macro will delete those columns if I can get the auto fill to stop at the last full cell in Column C
 
Upvote 0
try it this way then:

Code:
range("D2",range("C2").end(xldown).offset(,1)).formular1c1=range("D2").formular1c1
 
Upvote 0

Forum statistics

Threads
1,224,618
Messages
6,179,917
Members
452,949
Latest member
beartooth91

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