Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Not plot a data series in a chart but still display in data table mebp Charts and Charting in Excel 1 March 19th 10 05:13 PM
chart with two data series and two colors for each data series bikash Charts and Charting in Excel 0 January 17th 08 02:04 AM
hiding data series with check/uncheck boxes BigSmile Mannequins Inc. Charts and Charting in Excel 1 November 11th 06 10:24 AM
automatically expand chart data series as data is added jlarson Charts and Charting in Excel 1 March 9th 06 10:31 AM
chart data series -- plot a table as a single series hjc Charts and Charting in Excel 7 September 20th 05 05:52 PM


All times are GMT +1. The time now is 06:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"