VBA range select using offset and xldown

Timbo50

New Member
Joined
May 15, 2015
Messages
18
Office Version
  1. 2019
Platform
  1. Windows
I'm trying to use Vba to select a double column of data to create a range for a new chart. The data is added to daily, so I need to use xldown to capture the latest data but am having trouble selecting the range. I've been trying to incorporate offset to give the double column with xldown to go to last non-blank cell. Any help would be appreciated.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Assuming columns A & B from cell A1 to the last cell
Code:
dim lr as long
lr = cells(rows.count, "A").end(xlup).row
range("A1:B" & lr).select
 
Upvote 0
Hi Michael,

Many thanks, it works a treat. You made it look so simple after my complicated efforts. Thanks again.

Regards,
Tim.
 
Upvote 0
pleasure...(y)

Keep in mind though, that you generally don't need to select a range to do something with it !!!
 
Upvote 0

Forum statistics

Threads
1,216,114
Messages
6,128,913
Members
449,478
Latest member
Davenil

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