Hi
I am using this code to automatically update the data series in a chart based on the month (extract only):
Sub AddNewWorkedSeries()
If Range("I3").Value = "1" Then
With ActiveChart.SeriesCollection.NewSeries
.Name = "Worked"
.Values = Sheets("Sheet1").Range("B19:AF19")
.XValues = Sheets("Sheet1").Range("B4:AF4")
End With
End If
If Range("I3").Value = "2" Then
With ActiveChart.SeriesCollection.NewSeries
.Name = "Worked"
.Values = Sheets("Sheet1").Range("B20:AF20")
.XValues = Sheets("Sheet1").Range("B4:AF4")
End With
where I3 is the month of year ("1" = January, "2" = February, etc)
This works fine for a chart with only one Y-axis. But I have now been asked to add a second Y-axis to the same chart. The X-axis will remain unchanged.
Does anyone know how to modify this code so it only updates the data series for the second Y-axis without affecting the data series already updated for the first Y-axis?
Thanks
R
I am using this code to automatically update the data series in a chart based on the month (extract only):
Sub AddNewWorkedSeries()
If Range("I3").Value = "1" Then
With ActiveChart.SeriesCollection.NewSeries
.Name = "Worked"
.Values = Sheets("Sheet1").Range("B19:AF19")
.XValues = Sheets("Sheet1").Range("B4:AF4")
End With
End If
If Range("I3").Value = "2" Then
With ActiveChart.SeriesCollection.NewSeries
.Name = "Worked"
.Values = Sheets("Sheet1").Range("B20:AF20")
.XValues = Sheets("Sheet1").Range("B4:AF4")
End With
where I3 is the month of year ("1" = January, "2" = February, etc)
This works fine for a chart with only one Y-axis. But I have now been asked to add a second Y-axis to the same chart. The X-axis will remain unchanged.
Does anyone know how to modify this code so it only updates the data series for the second Y-axis without affecting the data series already updated for the first Y-axis?
Thanks
R