Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Making one Range out of two

Hi,

I have a function that, given a Range of cells, performs some
calculation

Say it can be called like this: =Compute(Rng)

However, I sometimes need that the Range "Rng" be made out of two
simpler ones:

Say I call the function with:

Compute(SomeFunc(A1:A10,C1:C10))

But that I want Compute to behave as if there was only a single Range.

Using some Excel built-in functions (union ranges?) puts me in an
ambiguous situation, since I never know if the union is made
horizontally wise, getting a range that is 10X2 (rows X columns) or
else vertically wise, getting a range that is 20X1.

Does anybody have some ideas as to how could I build SomeFunc"?

Thank you.

Vicente Soler
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,059
Default Making one Range out of two

"vsoler" wrote:
Say it can be called like this: =Compute(Rng)

However, I sometimes need that the Range "Rng" be
made out of two simpler ones


Does this solve your problem?

=doit((A1:A10,C1:C10))

Function doit(rng As Range)
Dim cell As Range
For Each cell In rng
Debug.Print cell.Address
Next cell
End Function

Output:

$A$1
$A$2
.....
$A$9
$A$10
$C$1
$C$2
.....
$C$9
$C$10


Using some Excel built-in functions (union ranges?)
puts me in an ambiguous situation, since I never know
if the union is made horizontally wise, getting a
range that is 10X2 (rows X columns) or else vertically
wise, getting a range that is 20X1.


Looks to me like it traverses horizontally first, then vertical.

For example, for:

=doit((A1:B10,C1:Z2))

the output is:

$A$1
$B$1
.....
$A$10
$B$10
$C$1
$D$1
.....
$Y$1
$Z$1
$C$2
$D$2
.....
$Y$2
$Z$2


----- original message -----

"vsoler" wrote in message
...
Hi,

I have a function that, given a Range of cells, performs some
calculation

Say it can be called like this: =Compute(Rng)

However, I sometimes need that the Range "Rng" be made out of two
simpler ones:

Say I call the function with:

Compute(SomeFunc(A1:A10,C1:C10))

But that I want Compute to behave as if there was only a single Range.

Using some Excel built-in functions (union ranges?) puts me in an
ambiguous situation, since I never know if the union is made
horizontally wise, getting a range that is 10X2 (rows X columns) or
else vertically wise, getting a range that is 20X1.

Does anybody have some ideas as to how could I build SomeFunc"?

Thank you.

Vicente Soler


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Making one Range out of two

In order to get the best answer for your question, I think you will need to
tell us what it is that your function is doing with the ranges passed into
it. If your code is not too long, post that would help as well.

--
Rick (MVP - Excel)


"vsoler" wrote in message
...
Hi,

I have a function that, given a Range of cells, performs some
calculation

Say it can be called like this: =Compute(Rng)

However, I sometimes need that the Range "Rng" be made out of two
simpler ones:

Say I call the function with:

Compute(SomeFunc(A1:A10,C1:C10))

But that I want Compute to behave as if there was only a single Range.

Using some Excel built-in functions (union ranges?) puts me in an
ambiguous situation, since I never know if the union is made
horizontally wise, getting a range that is 10X2 (rows X columns) or
else vertically wise, getting a range that is 20X1.

Does anybody have some ideas as to how could I build SomeFunc"?

Thank you.

Vicente Soler


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
Making all references in a range absolute Kasper Excel Discussion (Misc queries) 1 March 9th 09 02:09 PM
making a named range available from an add-in Solutions Manager Excel Programming 2 January 19th 09 03:18 PM
Making array from range René[_2_] Excel Programming 2 October 4th 05 06:28 AM
making the range a set of data within a column RFKFREAK Excel Worksheet Functions 1 August 27th 05 01:27 AM
Making a relative range in VBA aapjaap Excel Programming 1 October 10th 03 02:17 AM


All times are GMT +1. The time now is 07:03 PM.

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"