peterputter
New Member
I have a sheet with 26 Named Ranges and I only want to plot those which I choose with the script below, however when it executes it plots them all. What am I doing wrong?
Also, the ChartTitle line uses the new chart tab name, not the originating data tab. How can I change this?
Thanks!
Also, the ChartTitle line uses the new chart tab name, not the originating data tab. How can I change this?
Thanks!
Code:
Sub Chart1()
Dim cht As Chart
Set cht = Charts.Add
With cht
.ChartType = xlXYScatter
.HasTitle = True
.ChartTitle.Text = ActiveSheet.Name ' Would this be the original data sheet tab name!
.SeriesCollection.NewSeries
.SeriesCollection(1).Name = "=Data!$E$1"
.SeriesCollection(1).XValues = "=CreateNames.xls!YearMth"
.SeriesCollection(1).Values = "=CreateNames.xls!Units"
.SeriesCollection.NewSeries
.SeriesCollection(2).AxisGroup = xlSecondary
.SeriesCollection(2).Name = "=Data!$F$1"
.SeriesCollection(2).Values = "=CreateNames.xls!Unit_Cost"
End With
End Sub