LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default using UNION via Automation = invalid range result!?

Excel Gurus: HELP!

I am automating Excel via VBA from Access.
1) I have valid objects for the Applicaiton, and workbook, and i *know* the
ranges I am working with are NOT EMPTY.
2) the ranges ARE all on the same worksheet.

the problem:
I am building a chart, and the chart has multiple series of data to graph.
The chart has a category X axis.
The lists of Series Categories aren't necessarily all identical, so I need
to build a range which encompases all the unique category values across all
the series.

My method is to build an initial list of known-unique names (a subset of the
final list)
and use a little code in nested for each loops to identify all those items
in subsequent ranges which aren't already in the initial range, and UNION the
cell.Address(External:=True) to the previous range (making a discontiguous
range that points to a complete but also unique list of category values.

The problem I am having is that when I call the UNION method as follows, the
result is an INVALID range address string!
Ex:
Debug.Print "Pre-UNION oTempDRI.RangeAddress="; oTempDRI.RangeAddress
Debug.Print "n.address="; n.Address(External:=True)

oTempDRI.RangeAddress = _
xlA.Union( _
xlA.Range(oTempDRI.RangeAddress), _
xlA.Range(n.Address(External:=True)) _
).Address(External:=True)

Debug.Print "Post-UNION oTempDRI.RangeAddress="; oTempDRI.RangeAddress

Result in debug window:
Pre-UNION
oTempDRI.RangeAddress=[Sheet1]DatarptCorpIncidentsBarsAndLine!$B$2:$B$14
n.address=[Sheet1]DatarptCorpIncidentsBarsAndLine!$B$26
Post-UNION oTempDRI.RangeAddress=
[Sheet1]DatarptCorpIncidentsBarsAndLine!$B$2:$B$14,$B$26

Pre-UNION oTempDRI.RangeAddress=
[Sheet1]DatarptCorpIncidentsBarsAndLine!$B$2:$B$14,$B$26
n.address=[Sheet1]DatarptCorpIncidentsBarsAndLine!$B$28

The 2nd pass through my loop, the .Range method blows up on the
UNION-supplied address string (even with (External:=True) being used?!

Any thoughts/advice?
....or am I just going to have to do some string surgery to manually stuff
the "[...]...!" part of the address back into the resultant string after the
last "," myself?

 
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
union range Curt Excel Discussion (Misc queries) 9 April 20th 07 02:32 PM
union range problem Walter Excel Programming 2 May 13th 06 12:28 AM
Excel Not showing any result after Automation padu.oombans.friend Excel Programming 0 February 28th 06 03:51 PM
Union/Range/Cells KentÄ[_3_] Excel Programming 2 March 11th 05 11:14 AM
Union method for Range Object Chad Excel Programming 5 March 10th 05 08:02 PM


All times are GMT +1. The time now is 12:06 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"