Select Range Help

Dannyh1

Well-known Member
Joined
Nov 18, 2009
Messages
1,144
Hi,

I have the following code

Code:
Range(Selection, Selection.End(xlUp)).Select

At the moment this would select Range A100:A1

What I need it to do it select Range A100:A2

Help would be appreciated.

Many thanks,
Danny.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
The ".End(xlUp))" goes up untill the first nonempty cell (or vice versa).

If your code currently selects A1:A100 it looks like you have selected A100. To make it stop at A2 you can either type something in A2 (if the rest of the range is empty) or clear A1 (if the range is filled with values).

If you want to have your code "shoot up 'till the end and then come down one row" change your code to
Code:
Range(Selection, Selection.End(xlUp)).offset(1,0).Select
This only selects A2:A100 if your whole range is either empty or has values - and your active cell happens to be A100.
 
Upvote 0
Hi,

Try:

Code:
Range(Selection, "A" & Range(Selection, Selection.End(xlUp)).Row + 1).Select
Or, try from the top down (plus with this you don't have to select a cell):

Code:
Range("A2", "A" & Range("A2").End(xlDown).Row).Select
 
Upvote 0
Thanks Misca,

However I tried this approah previously, what I get in this situation is range A2:A101 as it offsets the enitre selection

I'm sure offset must come into it by I can't figure out where!
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,633
Members
452,933
Latest member
patv

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