Range selection rule?

D

dk_

What is the rule for selecting ranges of non-adjacent sections?
What is going on with my selection range below?

If I try to add just one more range of cells after 'J104'
in the range below, then Excel97 quits.

I have been unable to find what is wrong here?
I can add just one more individual cell after 'J104",
but not a range, not even a range of even 2 cells.


Range("C14:C25,C27:C34,C36:C38,C40:C48,C52:C59,C61:C68,C70:C72,C74:C77,C7
9:C80,C82:C86,C88:C91,C93:C95,C95,C93:C95,C97:C100,C104:C118,C121:C125,C1
27:C136,C138:C144,C146:C147," _
&
"C150:C152,C155,C157,C159:C162,C164:C173,C175:C185,C189:C195,J14:J16,J18:
J25,J27:J48,J51:J58,J59:J67,J69,J71:J99,J103:J104").Select


-Dennis
 
D

Dave Peterson

The length of the string for the addresses is too long.

How about

dim r1 as range
dim r2 as range
dim r3 as range
'as many as you need
dim rAll as range

set r1 = range("c14:c25,c27:c34....") 'lots of addresses
set r2 = range("more addresses")
set r3 = range("even more addresses")
'as many as you need

set rAll = union(r1,r2,r3,...)

rAll.select
 
D

dk_

Dave,

Thank you once again for a lesson.

I figured that there were too many parts in my range, but what is the
Excel rule for how many parts may be selected? I haven't been able to
find that info in the help program.

Same question for 'naming' ranges?

Any other rules that I should be aware of for selecting or defining
ranges?

Thanks again.

-Dennis
 
D

Dave Peterson

It's not really too many parts in the range (well, yet). It's too many parts in
that string that you use to define the range.

I _think_ that the limit is 256 characters (or about that). I usually keep
adding until it breaks, then swear a little bit and go back to fix it.

And the same technique can be used for naming a range.

rAll.name = "someName"

The first thing I'd suggest is stop selecting the range--for most purposes, you
can work directly on that range without any select's.
 
D

dk_

Ahhh, ...256 character limit. So, that's the deal. ;)

Regarding not selecting, ...I just used select to test and see the
range. I do try to avoid using ',select' when not needed. I learned that
in this group.

Now, you partially anwered another question that I was saving, and that
was about the Naming.

If I use your example ' rAll.name = "someName" ', does that name appear
in the Define Name box and the drop down Name Box Menu? If not, how do I
get the name to be there?

-Dennis
 
D

Dave Peterson

Did it show up in the namebox dropdown when you tried it?

Somethings can be tested quicker than asking and waiting for an answer <bg>.
 
D

dk_

I didn't test it, and I realized that I should have, before posting
another question.

-Dennis
 
D

dk_

Regarding the guess at a 256 character limit, that's not it. I just
checked. The range that works is 298 characters, and with code
surrounding the range it's 298 characters, and I could add one more
cell, for another 4 characters (and that was the limit).

There must be another rule operating that limits how a range can be
described.

-Dennis
 
D

dk_

Come' on, someone must know the rule. ;)
Excel is not as generous as living with a rule that says, "298 or 256
whatever."

-Dennis
 
D

Dave Peterson

How about you doing some testing and then post back with your results.

Personally, I'll never remember what that number is (as I've shown!). I just
remember that long strings cause trouble and know that I have to work around
them.

Do you actually think that you'll remember this exact number in a couple of
months? <vbg>
 
D

dk_

Dave,

I agree that the number is not really not important. I was thinking that
there is some other rule operating, and that someone else might chime in
here with the real answer.

Thanks for hanging in there. :)

-Dennis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top