I have a chart with a collection series. I would like to extend the range of the collection series by one column to the right. The code below works. However, it assumes that I know the range of the collection series ("B36:DA36" in the example below). In fact, I would like the initial range of the collection series (before resizing) to be defined in a dynamic way as it changes every day and defining it as below would not do the job.
Sub resize_collection_series()
Dim NumRows As Long
Dim NumCols As Long
Dim Rng As Range
Set Rng = Range("B36:DA36")
NumRows = Rng.Rows.Count
NumCols = Rng.Columns.Count
Worksheets("Sheet1").Activate
ActiveSheet.ChartObjects("Chart 6").Activate
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).Values = Rng.Resize(, NumCols + 1)
ActiveChart.SeriesCollection(1).XValues = Rng.Resize(, NumCols + 1)
End Sub
I tried something like this withouth success:
Set Rng = Worksheets("Sheet1").ChartObjects("Chart 6").SeriesCollection(1)
Set Rng = Worksheets("Sheet1").ChartObjects("Chart 6").SeriesCollection(1).Values