I am new to VBA chart programing. "Chart 1" on the attached sheet was created with an .AddChart2 macro, but I cannot get SeriesCollection.Extend to work. If I try to add the RowCol variable I get a compile error. Running the macro as is Gives a Subscript Out of Bounds error. What am I doing wrong? I wish to add the next two rows of data to the chart.
Macro:
Sub ExtendTrial()
Charts("Chart 1").SeriesCollection.Extend _
Source:=Worksheets("Sheet1").Range("A6:B8")
End Sub
ChartMacros.xlsm | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | |||
1 | DATE | VALUE | ||||||||||||
2 | 6/15/2023 | 1 | ||||||||||||
3 | 6/16/2023 | 4 | ||||||||||||
4 | 6/17/2023 | 9 | ||||||||||||
5 | 6/18/2023 | 16 | ||||||||||||
6 | 6/19/2023 | 25 | ||||||||||||
7 | 6/20/2023 | 36 | ||||||||||||
8 | 6/21/2023 | 49 | ||||||||||||
9 | 6/22/2023 | 64 | ||||||||||||
10 | 6/23/2023 | 81 | ||||||||||||
11 | ||||||||||||||
12 | ||||||||||||||
13 | ||||||||||||||
14 | ||||||||||||||
15 | ||||||||||||||
16 | ||||||||||||||
17 | ||||||||||||||
18 | ||||||||||||||
19 | ||||||||||||||
Sheet1 |
Macro:
Sub ExtendTrial()
Charts("Chart 1").SeriesCollection.Extend _
Source:=Worksheets("Sheet1").Range("A6:B8")
End Sub