Chart Title as a Cell in a worksheet
You need to do the X and Y values separately:
ActiveChart.SeriesCollection(1).XValues = "=Book2!XRange"
ActiveChart.SeriesCollection(1).Values = "=Book2!YRange"
or
ActiveChart.SeriesCollection(1).XValues = "='Sheet4 (2)'!XRange"
ActiveChart.SeriesCollection(1).Values = "='Sheet4 (2)'!YRange"
Macro:
Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SetSourceData Source:=Sheets("Sheet4 (2)").Range("G23:H27"),
_
PlotBy:=xlColumns
ActiveChart.SeriesCollection(1).XValues = "=Book2!XRange"
ActiveChart.SeriesCollection(1).Values = "=Book2!YRange"
ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet4 (2)"
--
Regards,
Tom Ogilvy
"John Baker" wrote in message
...
Tom:
To make things simple, I set up a chart and then recorded a macro to
change the data
ranges (which I did with cells initially), I then subsituted a named range
for the cells
as in:
Sub setparms()
'
' setparms Macro
' Macro recorded 10/02/2004 by John H Baker
'
'
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartArea.Select
ActiveChart.SetSourceData Source:=data!plotdata, PlotBy:= _
xlColumns
ActiveWindow.Visible = False
Windows("ReportNameChart.xls").Activate
End Sub
Chart1 is the chart. However, it does not care for the "data!plotdata"
reference, which is
sheet and named range. I also tried "plotdata" and that was not accepted
either. Is this a
flaw in my syntax or am I barking up the wrong tree?
John Bakler
"Tom Ogilvy" wrote:
in the dialog for assigning ranges
=Sheetname!RangeName
or
=BookName.xls!RangeName
works for me.
|