VBA - Last row & Autofill

LeeBillington

Board Regular
Joined
Dec 31, 2016
Messages
89
Hi,

So i am trying to find last column of B with data. then my current selection(Varies per day) to be autofilled down to the last column.

Not sure how to excecute it at all.

thanks
 

Some videos you may like

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

alansidman

Well-known Member
Joined
Feb 26, 2007
Messages
6,069
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I am guessing that you want the last "row" in column B and not the last "column" as B is a column.

To find the last row

VBA Code:
Dim lr as long
lr = Range("B" & rows.count).end(xlup).row

You have not indicated what you wish to fill down. Are you copying the same value into all rows or is it a sequential number you wish to fill down?
 

LeeBillington

Board Regular
Joined
Dec 31, 2016
Messages
89
I am guessing that you want the last "row" in column B and not the last "column" as B is a column.

To find the last row

VBA Code:
Dim lr as long
lr = Range("B" & rows.count).end(xlup).row

You have not indicated what you wish to fill down. Are you copying the same value into all rows or is it a sequential number you wish to fill down?

Oh sorry, yes the last row of column B, and there will be data ill manually put into the selection of like 5 cells, (formula in the selection and that needs to be autofilled down to the last row of B)
 

alansidman

Well-known Member
Joined
Feb 26, 2007
Messages
6,069
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
 

LeeBillington

Board Regular
Joined
Dec 31, 2016
Messages
89

so im using this,
Selection.AutoFill Destination:=Range("B6:B" & Range("E" & Rows.Count).End(xlUp).Row)
Range(Selection, Selection.End(xlDown)).Select

and i keep getting the error.. autofill method of range class failed.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,514
Messages
5,602,093
Members
414,501
Latest member
mdhaumyu

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