XL2000: Error Using Delete Method to Remove a Data Series From a PivotChart

ID: Q210735


The information in this article applies to:
  • Microsoft Excel 2000


SYMPTOMS

When you run a Microsoft Visual Basic for Applications macro, you receive the following error message:

Run-time error '1004':

Delete method of Series class failed


CAUSE

This error message occurs when you attempt to use the Delete method of the SeriesCollection object to delete a data series from a PivotChart.


WORKAROUND

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Solution Provider or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Solution Providers, please see the following page on the World Wide Web:

http://www.microsoft.com/mcsp/
For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp
The method that you use to remove a data series from being displayed on a PivotChart depends on the layout of the PivotChart. If your PivotChart contains more than one data series, then you must hide, rather than remove, the data series that you do not want displayed on the PivotChart. To do this, set the Visible property of the PivotItem object that you want to hide to False. The following line of code illustrates how to do this:

ActiveChart.PivotLayout.PivotFields("Year").PivotItems("1996") _
   .Visible = False 
If your PivotChart contains only one data series, then set the Orientation property of the PivotField object that you want to hide to xlHidden. The following line of code illustrates how to do this:

ActiveChart.PivotLayout.PivotFields("Sum of Sales").Orientation = xlHidden 
NOTE: The PivotChart and the related PivotTable report will be empty after Excel executes this line of code.

The following sample code illustrates how to detect whether or not the current chart is a PivotChart.

If ActiveChart.PivotLayout Is Nothing Then
    MsgBox "This is a normal chart."
Else
    MsgBox "This is a PivotChart."
End If 

Additional query words: XL2000

Keywords : kbdta kbdtacode kbchart xlvbahowto xlpivot
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: August 3, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.