Results 1 to 2 of 2
Thread: Changing charts with VBA (2003)
2008-11-24, 09:33 #1
- Join Date
- Jul 2008
- Suffolk, United Kingdom
- Thanked 0 Times in 0 Posts
Changing charts with VBA (2003)
I am using a drop down to select departments on cell B2 of an excel sheet, on update it changes the chart series name and values. The problem I have is when I change the drop down the chart adds the new series names and values but retains the old series although it does rename them to series3, series 4 etc where the number is the first number after the series names added by the vba on change event.
I have been messing about with the following bits of code and getting no where, any help would be great.
ActiveChart.SeriesCollection(1).Delete only works if the object exsits, I was trying to creat some sort of count then loop that number of times. I no the following wont work but to give an idea what I'm trying to achieve.
Dim i As Integar
For i = 1 to ActiveChart.SeriesCollection.Count
Gerbil (AKA Kevin)
2008-11-24, 09:38 #2
- Join Date
- Mar 2002
- Thanked 28 Times in 28 Posts
Re: Changing charts with VBA (2003)
If you want to delete series, you must loop backwards:
Dim i As Integer
For i = ActiveChart.SeriesCollection.Count To 1 Step -1