+ Reply to Thread
Results 1 to 3 of 3

Delete Chart Series if exists

Hybrid View

krish T Delete Chart Series if exists 10-11-2010, 02:02 PM
Andy Pope Re: Delete Chart Series if... 10-12-2010, 03:59 AM
krish T Re: Delete Chart Series if... 10-12-2010, 12:52 PM
  1. #1
    Forum Contributor
    Join Date
    10-01-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    125

    Delete Chart Series if exists

    I have surprising problem:

    When I am using the following code to create new chart:

    Charts.Add
    Sometimes immediately after this command, it is adding Series1 and sometimes it is not adding any Sereis..So I am adding new series using the following commands:

        ActiveChart.ChartType = xlXYScatterLinesNoMarkers
    
     ActiveChart.ChartArea.Select
    
               ActiveChart.SeriesCollection.NewSeries
               ActiveChart.SeriesCollection(1).XValues = Range(Sheets("Sheet1").Cells(5, 1), Sheets("Sheet1").Cells(4 + numtp, 1))
               ActiveChart.SeriesCollection(1).Values = Range(Sheets("Sheet1").Cells(5, 2), Sheets("Sheet1").Cells(4 + numtp, 2))
               ActiveChart.SeriesCollection(1).Name = ""KList1"
    I am giving name to series using the above command. But problem is if it is adding series 1 immediately after
    Charts.Add
    command, it still remains in the chart. So I would like to delete if this Series1 exists immediately after
    Charts.Add
    command.

    Can any body help me on this?

    Thanks in advance.
    Last edited by krish T; 10-12-2010 at 12:54 PM. Reason: solved the problem

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Delete Chart Series if exists

    If the active cell is within data series will automatically be added.
    To remove the series use,

    do while activechart.seriescollection.count > 0
        activechart.seriescollection(1).delete
    loop
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Contributor
    Join Date
    10-01-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    125

    Re: Delete Chart Series if exists

    Thanks Andy Pope. Its worked fine.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1