Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

This article was previously published under Q210735

↑ Back to the top


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

↑ Back to the top


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.

↑ Back to the top


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
				

↑ Back to the top


Keywords: KB210735, kbdtacode, kbprb, kbchart, kberrmsg

↑ Back to the top

Article Info
Article ID : 210735
Revision : 6
Created on : 9/12/2006
Published on : 9/12/2006
Exists online : False
Views : 261