Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Setting a variable to represent a union

I am trying to set up a macro which will draw a graph based on a range
where there are non-connected ranges (i.e. A1:F10, and H1:H10). I have
gotten unions to select the given ranges as follows

Dim myrange as range
Set myrange = Union(baserng, subrng1, subrng2)


Then if I do myrange.Select I get the range I would want selected. Now
when I try to put that into my graphing macro I can't get it to work:

With .Chart
..ChartType = xl3DColumnClustered
..SetSourceData Source:=Sheets(tempsheet).Range(myrange) _
, PlotBy:=xlRows

How do I phrase that .Setsourcedata line so this will work? Thanks in
advance.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Setting a variable to represent a union

Assuming this would work manually, try:


With .Chart
..ChartType = xl3DColumnClustered
..SetSourceData Source:=myrange _
, PlotBy:=xlRows

--
Regards,
Tom Ogilvy


"Chip" wrote in message
oups.com...
I am trying to set up a macro which will draw a graph based on a range
where there are non-connected ranges (i.e. A1:F10, and H1:H10). I have
gotten unions to select the given ranges as follows

Dim myrange as range
Set myrange = Union(baserng, subrng1, subrng2)


Then if I do myrange.Select I get the range I would want selected. Now
when I try to put that into my graphing macro I can't get it to work:

With .Chart
.ChartType = xl3DColumnClustered
.SetSourceData Source:=Sheets(tempsheet).Range(myrange) _
, PlotBy:=xlRows

How do I phrase that .Setsourcedata line so this will work? Thanks in
advance.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Setting a variable to represent a union

Chip,

Try

With .Chart
..ChartType = xl3DColumnClustered
..SetSourceData Source:= myrange , PlotBy:=xlRows

--
HTH

-------

Bob Phillips
"Chip" wrote in message
oups.com...
I am trying to set up a macro which will draw a graph based on a range
where there are non-connected ranges (i.e. A1:F10, and H1:H10). I have
gotten unions to select the given ranges as follows

Dim myrange as range
Set myrange = Union(baserng, subrng1, subrng2)


Then if I do myrange.Select I get the range I would want selected. Now
when I try to put that into my graphing macro I can't get it to work:

With .Chart
.ChartType = xl3DColumnClustered
.SetSourceData Source:=Sheets(tempsheet).Range(myrange) _
, PlotBy:=xlRows

How do I phrase that .Setsourcedata line so this will work? Thanks in
advance.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Setting a variable to represent a union

Tom that worked perfectly. I just have one follow up question. As I
mentioned earlier I am trying to have it graph a non-connected range
((i.e. A1:F10, and H1:H10). Earlier in the macro I have it graph a
connected range (i.e. A1:H10) and when it does that excel figured out
that A2:F2 are names for the entries, G2:H2 are data and G1:H1 are Cat.
X Labels. And the A2:F2, and G2:H2 changing for each data series.

When I do it disconnected it gets it all wrong. It thinks the names
are A1, A2, A3, A4, etc. for each data series (rather than A1:F1 which
is what I want), because it thinks the data values are B1:F1, and G1
(the non-connected data point). Do you know how to fix that in VBA?
Also it has no Category X labels which I would like to have set as the
first cell in the columns chosen in myrange from earlier?
Again, Tom Thanks!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Setting a variable to represent a union

Thank you Bob for the help as well.

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
Using a variable to represent the pathname in a formula David Jones Excel Discussion (Misc queries) 5 November 24th 06 04:37 AM
Setting variable = to sheet name Jeff Armstrong Excel Programming 2 July 26th 04 08:57 PM
setting a range variable equal to the value of a string variable Pilgrim Excel Programming 2 July 1st 04 11:32 PM
Setting range value to a variable Todd Excel Programming 4 June 2nd 04 04:51 PM
Using a variable to represent a Checkbox Name(OLEObject) Mike Cooper Excel Programming 1 July 16th 03 09:40 PM


All times are GMT +1. The time now is 02:29 AM.

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"