I
inquirer
I am having trouble with using named ranges. I want to use them to create
charts in code.
I have
srt = Cells(1, i).Value & "_sort"
cmf = Cells(1, i).Value & "_cumf"
ActiveWorkbook.Names.Add Name:=srt, RefersTo:=Range(Cells(2, 5),
Cells(lastrow, 5))
ActiveWorkbook.Names.Add Name:=cmf, RefersTo:=Range(Cells(2, 7),
Cells(lastrow, 7))
and this set up the named ranges ok. The I want to add a chart:
ActiveChart.ChartType = xlXYScatter
ActiveChart.SetSourceData Source:=Sheets("Data").Range("a1"),
PlotBy:=xlColumns
ActiveChart.SeriesCollection(1).XValues = "'Data'!srt"
ActiveChart.SeriesCollection(1).Values = "'Data'!cmf"
This fails at the last line with "Unable to set the Values property...."
Could someone tell me what the syntax is please and what the difference is
between the last 2 lines, why one works and one doesn't?
Thanks
Chris
charts in code.
I have
srt = Cells(1, i).Value & "_sort"
cmf = Cells(1, i).Value & "_cumf"
ActiveWorkbook.Names.Add Name:=srt, RefersTo:=Range(Cells(2, 5),
Cells(lastrow, 5))
ActiveWorkbook.Names.Add Name:=cmf, RefersTo:=Range(Cells(2, 7),
Cells(lastrow, 7))
and this set up the named ranges ok. The I want to add a chart:
ActiveChart.ChartType = xlXYScatter
ActiveChart.SetSourceData Source:=Sheets("Data").Range("a1"),
PlotBy:=xlColumns
ActiveChart.SeriesCollection(1).XValues = "'Data'!srt"
ActiveChart.SeriesCollection(1).Values = "'Data'!cmf"
This fails at the last line with "Unable to set the Values property...."
Could someone tell me what the syntax is please and what the difference is
between the last 2 lines, why one works and one doesn't?
Thanks
Chris