Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Range(S) is a valid expression when S = "x,y".

Thought I'd share something I discovered:

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.

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.

That seems kind of amazing.

For a param to "resolve into" into "secondary" or "inline" params
strikes me, offhand, as the kind of capability you occasionally find
in a scripting language that you can't get in a compiled language.

***
  #2   Report Post  
Posted to microsoft.public.excel.programming
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)

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Range(S) is a valid expression when S = "x,y".

Rick:

Thanks very much for reply.

You are clearly right, and I am clearly wrong, on both counts.

On the first, I did not in fact check to see exactly what the extent
of the range returned by the expression was.

On the second, I took my zeal over indirectness one level too far. I
should have said:

If S = "MyCell1,MyCell2", where "MyCell1" and "MyCell2" are legit
range names, then the expression Range(S) returns a real range (which
I just tested & it works).

Which, as I said, to a quasi-newbie like myself, seems kinda amazing.

Thanks much again.

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

If U = "MyCell1,MyCell2", where "MyCell1" and "MyCell2"
are legit range names, then the expression Range(U)
returns a real range (which I just tested & it works).


First off, note that I changed your S variable back to the U variable so as
to match your initial setup. I did this because I wanted to draw your
attention to the fact that with this...

S = "MyCell1"
T = "MyCell2"

when I asked you if you had meant to write this...

U = S & "," & T

I did that because that would make...

U = "MyCell1,MyCell2"

which is what you referred to in your quoted text at the top of this reply.

--
Rick (MVP - Excel)


"Jim Luedke" wrote in message
...
Rick:

Thanks very much for reply.

You are clearly right, and I am clearly wrong, on both counts.

On the first, I did not in fact check to see exactly what the extent
of the range returned by the expression was.

On the second, I took my zeal over indirectness one level too far. I
should have said:

If S = "MyCell1,MyCell2", where "MyCell1" and "MyCell2" are legit
range names, then the expression Range(S) returns a real range (which
I just tested & it works).

Which, as I said, to a quasi-newbie like myself, seems kinda amazing.

Thanks much again.

***


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula to confirm entry in Col "C" is valid for data in Col "A" VAPCMD Excel Discussion (Misc queries) 2 January 2nd 09 07:58 PM
=IF(VLOOKUP(C11,Group,2,FALSE)=D11,"True","Not Valid") and =IF(D1 Milky Excel Worksheet Functions 1 August 20th 08 08:38 PM
Create pivot table, error "Range is not valid" Daniel Charts and Charting in Excel 3 July 12th 07 11:12 PM
use variable in Workbooks("book1").Worksheets("sheet1").Range("a1" Luc[_3_] Excel Programming 2 September 28th 05 08:37 PM
Excel expression "sumproduct" in Access fatfish Excel Programming 0 June 24th 04 03:17 PM


All times are GMT +1. The time now is 04:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"