View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Range(S) is a valid expression when S = "x,y".

See inline comments...

Let's say string S = "MyCell1", and MyCell1 is a valid range name.

Then of course, expression Range(S) returns the range.

Next, let's say string T = "MyCell2", and ditto.

Then, Range(S,T) returns a range comprising the two individual ranges.


This is not true. Say that MyCell1 referred to A1 and MyCell2 referred to
D4, then Range(S, T) would be A1:D4 (print out its address to see this)...
A1:D4 is *not* a range comprised of the two cells making up MyCell1 and
MyCell2.

Now, let's say string U = "S,T".

Then, expression Range(U) is equivalent to Range(S,T). Namely, it
returns the range comprising MyCell1 and MyCell2.


When I assign "S,T" to U and then try to print out Range(U).Address, I get
an error generated. Did you perhaps mean to write this?

U = S & "," & T

If so, the Range(U) would be equal to A1,D4 which is the two individual
cells assigned to MyCell1 and MyCell2, but this is not the same as
Range(S,T) which, as we saw above, was all the cells including and between
A1 and D4.

--
Rick (MVP - Excel)