Hello - I found this VBA that changes the data series for all of the charts in my workbook. Works great.
1. How do I change so that it only changes the charts on a sheet, and not the entire workbook...
2. Possible to also only change selected charts?
Thank you.
Sub ChangeAllCharts()
Dim sht As Worksheet
Dim cht As ChartObject
Dim ser As Series
For Each sht In ActiveWorkbook.Worksheets
For Each cht In sht.ChartObjects
For Each ser In cht.Chart.SeriesCollection
ser.Formula = Replace(ser.Formula, "$D$5:$D$26", "$D$5:$D$27")
Next ser
Next cht
Next sht
End Sub
1. How do I change so that it only changes the charts on a sheet, and not the entire workbook...
2. Possible to also only change selected charts?
Thank you.
Sub ChangeAllCharts()
Dim sht As Worksheet
Dim cht As ChartObject
Dim ser As Series
For Each sht In ActiveWorkbook.Worksheets
For Each cht In sht.ChartObjects
For Each ser In cht.Chart.SeriesCollection
ser.Formula = Replace(ser.Formula, "$D$5:$D$26", "$D$5:$D$27")
Next ser
Next cht
Next sht
End Sub
Last edited: