Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 183
Default SourceData for graph

If I use the following code, the CatTitle, ChartYear, SrcRange are graphed as
series.
I would like the CatTitle to be the title of the graph legend, the ChartYear
to be the Xaxis and the ScrRange the series to graph.
Can somebody help? thanks



Dim TheChartObj As ChartObject
Dim TheChart As Chart
Dim ChartYear As Range
Dim CatTitles As Range
Dim SrcRange As Range
Dim SourceData As Range

Set TheChartObj = ActiveSheet.ChartObjects(10)
Set TheChart = TheChartObj.Chart
Set SrcRange = Range(ActiveCell.Offset(0, 2), ActiveCell.Offset(0, 24))
Set ChartYear = Range("f3:ab3")
Set CatTitle = ActiveCell

Set SourceData = Union(CatTitle, ChartYear, SrcRange)

TheChart.SetSourceData _
Source:=SourceData, PlotBy:=xlRows

TheChartObj.Visible = True
--
caroline
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default SourceData for graph

Why not set the series name, values, and xvalues to the respective
ranges?

To get one form of the syntax, use the macro recorder. An alternative
would be direct range references along the lines of

ActiveChart.SeriesCollection(1).XValues = Range("c2:c5")
ActiveChart.SeriesCollection(1).Values = Range("d2:d5")
ActiveChart.SeriesCollection(1).Name = Range("C1")

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
If I use the following code, the CatTitle, ChartYear, SrcRange are graphed as
series.
I would like the CatTitle to be the title of the graph legend, the ChartYear
to be the Xaxis and the ScrRange the series to graph.
Can somebody help? thanks



Dim TheChartObj As ChartObject
Dim TheChart As Chart
Dim ChartYear As Range
Dim CatTitles As Range
Dim SrcRange As Range
Dim SourceData As Range

Set TheChartObj = ActiveSheet.ChartObjects(10)
Set TheChart = TheChartObj.Chart
Set SrcRange = Range(ActiveCell.Offset(0, 2), ActiveCell.Offset(0, 24))
Set ChartYear = Range("f3:ab3")
Set CatTitle = ActiveCell

Set SourceData = Union(CatTitle, ChartYear, SrcRange)

TheChart.SetSourceData _
Source:=SourceData, PlotBy:=xlRows

TheChartObj.Visible = True

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
Read SourceData from Chart Fernando Excel Programming 3 August 9th 05 04:46 AM
How to use ADO to change Pivottable sourcedata query Chace Excel Programming 0 May 17th 05 06:44 PM
PivotTableWizard SourceData question Microsoft Forum Excel Programming 3 February 26th 05 05:50 PM
SourceData in pivot table JIM.H.[_2_] Excel Programming 0 June 9th 04 12:59 AM
Setting up a SourceData:= in VB Emmanuel[_2_] Excel Programming 1 January 22nd 04 08:15 PM


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