Microsoft KB Archive/210735

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

Article ID: 210735

Article Last Modified on 9/12/2006

-

APPLIES TO


 * Microsoft Excel 2000 Standard Edition

-



This article was previously published under Q210735



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. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers 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 requirements. 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: kberrmsg kbchart kbprb kbdtacode KB210735

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.