Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excel.Union returning two Areas

I am baffled, for some reason the following lines in the immidiate
window

? Excel.Union(Range("$A$1:$M$88"),Range("$A$1:$Z$2") ).AddressLocal

Outputs:

$A$1:$M$88,$A$1:$Z$2

Which is a Range with two Areas. I was expecting $A$1:$Z$88, which is
what I need. How would I make sure that Union only returns Ranges with
a single Area?

Thanks,
Daniel
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Excel.Union returning two Areas

Hi
as you have not specified a range such as A1:Z88 with your UNION
statement why would you expect Excel would return this?. The Union
statement would return a single area if this is possible. e.g.
? Excel.Union(Range("$A$3:$Z$88"),Range("$A$1:$Z$2") )
would return
$A$1:$Z$88


--
Regards
Frank Kabel
Frankfurt, Germany

"Daniel" schrieb im Newsbeitrag
om...
I am baffled, for some reason the following lines in the immidiate
window

? Excel.Union(Range("$A$1:$M$88"),Range("$A$1:$Z$2") ).AddressLocal

Outputs:

$A$1:$M$88,$A$1:$Z$2

Which is a Range with two Areas. I was expecting $A$1:$Z$88, which is
what I need. How would I make sure that Union only returns Ranges

with
a single Area?

Thanks,
Daniel


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Excel.Union returning two Areas

Daniel,

Union is not the Range from the start of one range to the end of another.
Rather, Union returns a range object that encapsulates the ranges being
acted upon.

Thus, if these ranges have no overlapping area, the union will just return
an object that refers to the individual ranges.

Union(Range("A1"), Range("C1")) is of this type and will return a range
object of two areas.

If the ranges totally overlap (that is the smaller ones are all contained
within the largest) then the Union will return a range object the same as
the largest range.

Union(Range("H5:J10"), Range("I6:I8")) is of this type and will return a
range object for H5:J10

If they don't overlap but are contiguous (that is no columns or no rows
between them that are not in one of the ranges), and if the columns or the
rows of the ranges are identical, it will return a single range object of
the type you expect.

Union(Range("A1:C10"), Range("A6:C12")) is of this type and will return a
range object for A1:C12

--

HTH

RP

"Daniel" wrote in message
om...
I am baffled, for some reason the following lines in the immidiate
window

? Excel.Union(Range("$A$1:$M$88"),Range("$A$1:$Z$2") ).AddressLocal

Outputs:

$A$1:$M$88,$A$1:$Z$2

Which is a Range with two Areas. I was expecting $A$1:$Z$88, which is
what I need. How would I make sure that Union only returns Ranges with
a single Area?

Thanks,
Daniel



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Excel.Union returning two Areas

You have received good answers on Union. Perhaps what you want is this:

? Range(Range("$A$1:$M$88"),Range("$A$1:$Z$2")).Addr ess
$A$1:$Z$88

I believe this will give you the rectangle that can contain the two areas.
--
Regards,
Tom Ogilvy

"Daniel" wrote in message
om...
I am baffled, for some reason the following lines in the immidiate
window

? Excel.Union(Range("$A$1:$M$88"),Range("$A$1:$Z$2") ).AddressLocal

Outputs:

$A$1:$M$88,$A$1:$Z$2

Which is a Range with two Areas. I was expecting $A$1:$Z$88, which is
what I need. How would I make sure that Union only returns Ranges with
a single Area?

Thanks,
Daniel



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excel.Union returning two Areas

"Tom Ogilvy" wrote:
? Range(Range("$A$1:$M$88"),Range("$A$1:$Z$2")).Addr ess
$A$1:$Z$88


Thanks Tom (and the others). That is what I needed.
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
Get the row count of different areas in the Excel Curious[_2_] Excel Discussion (Misc queries) 2 July 8th 09 01:58 PM
SQL Union in MS Excel 2007 aireq Excel Discussion (Misc queries) 1 June 20th 09 07:58 PM
Excel - printing specific areas Gabriella Excel Discussion (Misc queries) 2 July 24th 08 04:29 PM
Bringing in a Union Query with excel? S Davis Excel Worksheet Functions 3 August 24th 06 06:52 PM
Equivalent of Minus in Excel. Also Union, Intersect. KARL DEWEY Excel Worksheet Functions 0 January 27th 06 10:47 PM


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

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

About Us

"It's about Microsoft Excel"