Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 63
Default defined names and setsourcedata

I have formula in a cell that creates a string. The string can represent
several defined names strung together, delimited by a comma. For example, the
formula in cell D21 returns:

AX,SY,KS

AX is actually a defined name for a range A1:A10 (the axis), SY = C1:C10,
and KS = E1:10

I'm trying to set the source data range in a chart on a different sheet to
the string I created in D21. Even if I name D21 as "makechart", it still
won't work.

Sub Macro5()
ActiveChart.SetSourceData Source:=ActiveWorkbook.Names("makechart"),
PlotBy:=xlColumns
End Sub

Please help.
Thanks.
Jason
  #2   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 10,593
Default defined names and setsourcedata

Dim rng As Range

Set rng = Union(Range("AX"), Range("SY"), Range("KS"))

ActiveChart.SetSourceData Source:=rng, PlotBy:=xlColumns



--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Jason Morin" wrote in message
...
I have formula in a cell that creates a string. The string can represent
several defined names strung together, delimited by a comma. For example,
the
formula in cell D21 returns:

AX,SY,KS

AX is actually a defined name for a range A1:A10 (the axis), SY = C1:C10,
and KS = E1:10

I'm trying to set the source data range in a chart on a different sheet to
the string I created in D21. Even if I name D21 as "makechart", it still
won't work.

Sub Macro5()
ActiveChart.SetSourceData Source:=ActiveWorkbook.Names("makechart"),
PlotBy:=xlColumns
End Sub

Please help.
Thanks.
Jason



  #3   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 6,582
Default defined names and setsourcedata

Bob's suggestion works fine. I wanted to explain why your one-liner doesn't
work.

SetSourceData takes a range as its Source argument.
ActiveWorkbook.Names("makechart") is a name, not a range. You could get
either of these to work:

ActiveChart.SetSourceData Source:=ActiveSheet.Range("makechart")
ActiveChart.SetSourceData
Source:=ActiveWorkbook.Names("makechart"),RefersTo Range

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Jason Morin" wrote in message
...
I have formula in a cell that creates a string. The string can represent
several defined names strung together, delimited by a comma. For example,
the
formula in cell D21 returns:

AX,SY,KS

AX is actually a defined name for a range A1:A10 (the axis), SY = C1:C10,
and KS = E1:10

I'm trying to set the source data range in a chart on a different sheet to
the string I created in D21. Even if I name D21 as "makechart", it still
won't work.

Sub Macro5()
ActiveChart.SetSourceData Source:=ActiveWorkbook.Names("makechart"),
PlotBy:=xlColumns
End Sub

Please help.
Thanks.
Jason



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
Invisible Defined Names TKS_Mark Excel Discussion (Misc queries) 3 September 11th 07 02:06 AM
How to keep names defined after a copy? Warda Excel Discussion (Misc queries) 0 December 5th 06 03:08 PM
NAMES DEFINED F. Lawrence Kulchar Excel Discussion (Misc queries) 5 November 14th 06 07:54 AM
List of defined names coa01gsb Excel Worksheet Functions 4 March 21st 06 04:53 PM
Defined names DREED Excel Discussion (Misc queries) 3 March 10th 06 02:55 PM


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