Autofill xldown offset three columns

Bench

Board Regular
Joined
Aug 27, 2009
Messages
134
Hi,

I've used the following formula many times to autofill to the last row based upon the adjacent column

Code:
Range("D5").AutoFill Destination:=Range("D5", Range("D5").Offset(0, -1).End(xlDown).Offset(0, 1))

For the code i'm currently writing Column's B & C will always have gaps in their data, therefore it needs to autofill based upon Column A, i've tried various modifications to try and accomplish but without success. Sure it's something fairly simple.

Your thoughts would be appreciated

Thanks

Ben
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
54,275
Office Version
  1. 365
Platform
  1. Windows
Range("A" & Rows.Count).End(xlUp)

This gives the bottom cell in column A. You should be able to use that with an Offset to achieve your goal,
 

AlphaFrog

MrExcel MVP
Joined
Sep 2, 2009
Messages
16,450
This will fill column C based on Column A

Code:
Range("C5").AutoFill Destination:=Range("A5", Range("A5").End(xlDown)).Offset(0, 2)

Or this...
Code:
Range("C5").AutoFill Destination:=Range("C5", Range("A5").End(xlDown).Offset(0, 2))
 
Last edited:

Bench

Board Regular
Joined
Aug 27, 2009
Messages
134
Range("A" & Rows.Count).End(xlUp)

This gives the bottom cell in column A. You should be able to use that with an Offset to achieve your goal,

Thanks, i'm still quite a beginner with VBA so not sure exactly how to execute that in code :(

Been playing a bit more and have come up with the below, this is so close to working, just fills down one short of where it needs to be.

Code:
Range("D5").AutoFill Destination:=Range("D5", Range("D5").Offset(0, -1).End(xlDown).Offset(4, 1))
 

Bench

Board Regular
Joined
Aug 27, 2009
Messages
134
thanks for your help folks, this one worked for me in the end

Code:
Range("D5").AutoFill Destination:=Range("D5", Range("A5").End(xlDown).Offset(-1, 3))
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,714
Messages
5,833,279
Members
430,201
Latest member
Deepakpilla36

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
Top