XL97: Incorrect Field Names Appear in PivotTable Field Dialog Box (202232)
The information in this article applies to:
- Microsoft Excel 97 for Windows
This article was previously published under Q202232 SYMPTOMS
In the PivotTable Field dialog box, the Hide Items list may display field names that are not contained within the source data range of the PivotTable.
CAUSE
This behavior occurs when the following conditions are true:
- You have changed any field names within that source data range for
the PivotTable, after initially creating the PivotTable.
-and-
- You click a field in a PivotTable, and then click the PivotTable Field button on the PivotTable toolbar.
-or-
- You right-click a field in a PivotTable and then click Field.
WORKAROUNDMicrosoft 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 Partner or the Microsoft fee-based
consulting line at (800) 936-5200. For more information about Microsoft Certified
Partners, please visit the following Microsoft Web site:
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
The following sample macro code deletes all of the fields in the PivotTable and then refreshes the PivotTable. Only the fields that are currently in the source data range will be displayed in the PivotTable Field dialog box.
- Write down the name of the worksheet that contains the PivotTable
(for example, "Sheet1") and the name of the PivotTable (for example,
"PivotTable1"). To determine the name of a PivotTable, right-click
any area of the PivotTable and click Options. The PivotTable
Options dialog box displays the name of the PivotTable. Click
OK to close the dialog box.
- On the Tools menu point to Macro, and click Visual Basic Editor. Or, press ALT+F11.
- On the Insert menu, click Module.
- Enter the following code:
Sub Delete_Fields()
On Error Resume Next
For Each pvtfield In Worksheets("X").PivotTables("Y").PivotFields
For Each pvtitem In pvtfield.PivotItems
pvtitem.Delete
Next
Next
ActiveSheet.PivotTables("Y").RefreshTable
End Sub
where "X" is the name of the worksheet you wrote down in step 1 and "Y" is the name of the PivotTable you wrote down in step 1. - On the File menu, click Close and Return to Microsoft Excel.
- On the Tools menu, point to Macro and click Macros. In the list of macros, click Delete_Fields, and then click Run.
Modification Type: | Major | Last Reviewed: | 6/23/2005 |
---|
Keywords: | kbdtacode kbprb KB202232 |
---|
|