Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dyl Dyl is offline
external usenet poster
 
Posts: 10
Default Using Named Range to Set DataSource in Chart

Hi,

I am trying to use a named Range which has been set in an earlier
function to use as the SourceData for a chart being created in
excel/vba code.

My code looks like this:

ActiveChart.SetSourceData Source:=XValues, PlotBy:=xlRows

When I run this code, only one cell's value from the "XValues" Range
appears on the X-Axis. I know the range consists of more than one cell
with different values. I have also tried setting PlotBy = xlColumns
and that does not work either.

I can create the graph just fine when I select the range and and create
a chart without vba.

I guess one option would be to select the range and see if that works,
but I don't really like to select cells in the code, but if that's the
only option, I'll do it.

Is there something I should be doing differently?

Thanks,
Dylan

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Using Named Range to Set DataSource in Chart

Hi Dylan,

Try

ActiveChart.SetSourceData Source:=Range("myNamedRange") ', etc

Regards,
Peter T


"Dyl" wrote in message
oups.com...
Hi,

I am trying to use a named Range which has been set in an earlier
function to use as the SourceData for a chart being created in
excel/vba code.

My code looks like this:

ActiveChart.SetSourceData Source:=XValues, PlotBy:=xlRows

When I run this code, only one cell's value from the "XValues" Range
appears on the X-Axis. I know the range consists of more than one cell
with different values. I have also tried setting PlotBy = xlColumns
and that does not work either.

I can create the graph just fine when I select the range and and create
a chart without vba.

I guess one option would be to select the range and see if that works,
but I don't really like to select cells in the code, but if that's the
only option, I'll do it.

Is there something I should be doing differently?

Thanks,
Dylan



  #3   Report Post  
Posted to microsoft.public.excel.programming
Dyl Dyl is offline
external usenet poster
 
Posts: 10
Default Using Named Range to Set DataSource in Chart

Peter,

Thanks for your help. Unfortunately this still does not work. I get
the following error.

Run-tine error '1004'

Method 'Range of object '_Global falied

I also tried to set the range in the same procedure, but I still got
the same error. (I had been getting the value from a function earlier)

I'll keep trying. Thanks again for your help!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Using Named Range to Set DataSource in Chart

Sounds like there's something wrong with your named range -

MsgBox ActiveWorkbook.Names("myNamedRange").RefersTo

MsgBox Range("myNamedRange").Address(, , , True)

Regards,
Peter T


"Dyl" wrote in message
oups.com...
Peter,

Thanks for your help. Unfortunately this still does not work. I get
the following error.

Run-tine error '1004'

Method 'Range of object '_Global falied

I also tried to set the range in the same procedure, but I still got
the same error. (I had been getting the value from a function earlier)

I'll keep trying. Thanks again for your help!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Using Named Range to Set DataSource in Chart

ActiveChart.SetSourceData Source:=ActiveSheet.Range("myNamedRange") ', etc

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


"Peter T" <peter_t@discussions wrote in message
...
Hi Dylan,

Try

ActiveChart.SetSourceData Source:=Range("myNamedRange") ', etc

Regards,
Peter T


"Dyl" wrote in message
oups.com...
Hi,

I am trying to use a named Range which has been set in an earlier
function to use as the SourceData for a chart being created in
excel/vba code.

My code looks like this:

ActiveChart.SetSourceData Source:=XValues, PlotBy:=xlRows

When I run this code, only one cell's value from the "XValues" Range
appears on the X-Axis. I know the range consists of more than one cell
with different values. I have also tried setting PlotBy = xlColumns
and that does not work either.

I can create the graph just fine when I select the range and and create
a chart without vba.

I guess one option would be to select the range and see if that works,
but I don't really like to select cells in the code, but if that's the
only option, I'll do it.

Is there something I should be doing differently?

Thanks,
Dylan







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Using Named Range to Set DataSource in Chart

Hi Jon,

ActiveSheet.Range("myNamedRange")
would fail if "myNamedRange" refers to a range that's not on the ActiveSheet

Regards,
Peter T


"Jon Peltier" wrote in message
...
ActiveChart.SetSourceData Source:=ActiveSheet.Range("myNamedRange") ', etc

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


"Peter T" <peter_t@discussions wrote in message
...
Hi Dylan,

Try

ActiveChart.SetSourceData Source:=Range("myNamedRange") ', etc

Regards,
Peter T


"Dyl" wrote in message
oups.com...
Hi,

I am trying to use a named Range which has been set in an earlier
function to use as the SourceData for a chart being created in
excel/vba code.

My code looks like this:

ActiveChart.SetSourceData Source:=XValues, PlotBy:=xlRows

When I run this code, only one cell's value from the "XValues" Range
appears on the X-Axis. I know the range consists of more than one cell
with different values. I have also tried setting PlotBy = xlColumns
and that does not work either.

I can create the graph just fine when I select the range and and create
a chart without vba.

I guess one option would be to select the range and see if that works,
but I don't really like to select cells in the code, but if that's the
only option, I'll do it.

Is there something I should be doing differently?

Thanks,
Dylan







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Using Named Range to Set DataSource in Chart

Of course. I was indicating that perhaps Range("") needs to be more fully
qualified.

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


"Peter T" <peter_t@discussions wrote in message
...
Hi Jon,

ActiveSheet.Range("myNamedRange")
would fail if "myNamedRange" refers to a range that's not on the
ActiveSheet

Regards,
Peter T


"Jon Peltier" wrote in message
...
ActiveChart.SetSourceData Source:=ActiveSheet.Range("myNamedRange") ',
etc

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


"Peter T" <peter_t@discussions wrote in message
...
Hi Dylan,

Try

ActiveChart.SetSourceData Source:=Range("myNamedRange") ', etc

Regards,
Peter T


"Dyl" wrote in message
oups.com...
Hi,

I am trying to use a named Range which has been set in an earlier
function to use as the SourceData for a chart being created in
excel/vba code.

My code looks like this:

ActiveChart.SetSourceData Source:=XValues, PlotBy:=xlRows

When I run this code, only one cell's value from the "XValues" Range
appears on the X-Axis. I know the range consists of more than one
cell
with different values. I have also tried setting PlotBy = xlColumns
and that does not work either.

I can create the graph just fine when I select the range and and
create
a chart without vba.

I guess one option would be to select the range and see if that works,
but I don't really like to select cells in the code, but if that's the
only option, I'll do it.

Is there something I should be doing differently?

Thanks,
Dylan









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
Dynamic Named Range for a Chart PFLY Excel Discussion (Misc queries) 1 February 11th 10 07:36 PM
Chart using named range Tigerxxx Excel Discussion (Misc queries) 1 October 18th 08 11:24 AM
need help using named range in chart Marc Pelletier Charts and Charting in Excel 4 September 29th 08 04:23 PM
Can I use named range in data range box when creating pie chart? BJackson Charts and Charting in Excel 2 August 17th 05 05:37 PM
named range refers to: in a chart Spencer Hutton Excel Discussion (Misc queries) 1 December 14th 04 10:15 PM


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