ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to id if range is correct? (https://www.excelbanter.com/excel-programming/376316-how-id-if-range-correct.html)

davegb

How to id if range is correct?
 
One of the things I have the most trouble with in VBA is figuring out
when I'm working with a range, if the range I want to be selected is
the correct one. Doing a watch doesn't help. Is the best way simply to
put in a temporary "range.select" and see if it's the correct one, or
is there a better way?

Thanks again!


Ron de Bruin

How to id if range is correct?
 
More information please ?


--
Regards Ron de Bruin
http://www.rondebruin.nl



"davegb" wrote in message oups.com...
One of the things I have the most trouble with in VBA is figuring out
when I'm working with a range, if the range I want to be selected is
the correct one. Doing a watch doesn't help. Is the best way simply to
put in a temporary "range.select" and see if it's the correct one, or
is there a better way?

Thanks again!




Gary''s Student

How to id if range is correct?
 
Try, instead,:

MSGBOX(myRange.Address)
--
Gary's Student


"davegb" wrote:

One of the things I have the most trouble with in VBA is figuring out
when I'm working with a range, if the range I want to be selected is
the correct one. Doing a watch doesn't help. Is the best way simply to
put in a temporary "range.select" and see if it's the correct one, or
is there a better way?

Thanks again!



NickHK

How to id if range is correct?
 
Not sure how you determine the correct range, but

Debug.Assert MyRange.Address=Selection.Address

However, it is seldom necessary to .select objects in order to work with
them, so you may (probably) not need the .select anyway.

NickHK

"davegb" wrote in message
oups.com...
One of the things I have the most trouble with in VBA is figuring out
when I'm working with a range, if the range I want to be selected is
the correct one. Doing a watch doesn't help. Is the best way simply to
put in a temporary "range.select" and see if it's the correct one, or
is there a better way?

Thanks again!




davegb

How to id if range is correct?
 

NickHK wrote:
Not sure how you determine the correct range, but

Debug.Assert MyRange.Address=Selection.Address

However, it is seldom necessary to .select objects in order to work with
them, so you may (probably) not need the .select anyway.

NickHK


Thanks for all your replies.

What I'm hearing is that VBA doesn't tell the user what range a range
variable represents. You have to do a select or a message box to find
out. That's not what I wanted to hear, but what I need to know!


"davegb" wrote in message
oups.com...
One of the things I have the most trouble with in VBA is figuring out
when I'm working with a range, if the range I want to be selected is
the correct one. Doing a watch doesn't help. Is the best way simply to
put in a temporary "range.select" and see if it's the correct one, or
is there a better way?

Thanks again!


Thanks for all your replies!

What I'm hearing is, the only way to know what range a range variable
is representing is a select or a msgbox, which amount to pretty much
the same thing. There's no built-in feature to id what a range is.



All times are GMT +1. The time now is 09:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com