Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA to check if there is a data series in a chart?
SeriesCollection.Count tells you how many series are present. They are
numbered 1 to N, and if SeriesCollection(i) exists, so does SeriesCollection(i-1). - Jon ------- Jon Peltier, Microsoft Excel MVP Peltier Technical Services Tutorials and Custom Solutions http://PeltierTech.com/ _______ JB2004 wrote: I am trying to create a macro that will update a chart based on a yes/no pull down menu's. It will grab data from other worksheets if the pull down menu indicates yes. A total of five data sets are possible. The problem I have is the logic that would determine if you need to add a newdata series or if you can overwrite an existing one. The logic would have to check if a seriescollection(1) or seriescollection(2)....etc. are there if not create one. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA to check if there is a data series in a chart?
Here's one that's a little simpler:
With ActiveSheet.ChartObjects(1).Chart Do While .SeriesCollection.Count N .SeriesCollection(.SeriesCollection.Count).Delete Loop End With - Jon ------- Jon Peltier, Microsoft Excel MVP Peltier Technical Services Tutorials and Custom Solutions http://PeltierTech.com/ _______ JB2004 wrote: Thank you for your response. Based off your response, I was able to develope a If...then and For...Next loop to check the seriescollection count to determine if a series needs to be deleted. Below is the code I used: Sheet1.Select ActiveSheet.ChartObjects(1).Select 'N is the number of series selected by user N = 2 'X is the total number of series ploted on chart X = ActiveChart.SeriesCollection.Count Z = X - N If Z 0 Then For G = 1 To Z + 1 X = ActiveChart.SeriesCollection.Count ActiveChart.SeriesCollection(X).Delete G = G + 1 Next End If |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Not plot a data series in a chart but still display in data table | Charts and Charting in Excel | |||
chart with two data series and two colors for each data series | Charts and Charting in Excel | |||
hiding data series with check/uncheck boxes | Charts and Charting in Excel | |||
automatically expand chart data series as data is added | Charts and Charting in Excel | |||
chart data series -- plot a table as a single series | Charts and Charting in Excel |