Pivot Table Issues

Fix Excel VBA PivotField.CurrentPage Error for Date Filters

Steve KSteve K Oct 19, 2026 868 views

Question details

The user is experiencing a VBA runtime error when attempting to assign a date or grouped year to PivotField.CurrentPage in an OLAP PivotTable.

How to Fix Excel VBA PivotField.CurrentPage Errors for Date Filters
Product
Microsoft Excel
Device & OS
not provided
Scenario
Automating OLAP PivotTable filtering using Excel VBA for date-based or grouped year fields.
Observed behavior
Excel VBA throws an error (such as Error 5) when PivotField.CurrentPage is assigned a standard date value instead of an OLAP unique name, or when PivotFilters.Add is used on a page filter.
Before you start

Before modifying your VBA script, ensure that your target PivotField is actually placed in the report filter area (page field) and verify the exact MDX unique name used by your data source.

Solution 1Recommended

Use the Exact OLAP Member Unique Name

Assign the complete MDX unique name to the CurrentPage property instead of just the displayed date or year string.

OLAP PivotTables do not accept simple string values for date filters. You must provide the exact hierarchy and member key that matches the data model's definition.

1
Verify Filter Placement

Ensure that the target PivotField is placed in the Report Filter area of your PivotTable before executing the script.

2
Determine the Unique Name

Find the correct OLAP hierarchy and member key. For example, use a format like [Verkopen].[Fact.datum (Jaar)].&[2023] instead of simply "2023".

3
Update the VBA Script

Assign the exact member unique name string directly to the PivotField.CurrentPage property in your VBA code.

Use the Exact OLAP Member Unique Name
Tip for Finding MDX Syntax: You can record a macro while manually applying the filter in your OLAP PivotTable. The recorded code will reveal the exact MDX syntax and unique name required.
Free Microsoft Office alternative

Try WPS Office for Seamless Data Analysis

If you frequently encounter complex macro or OLAP issues in Microsoft Excel, consider WPS Office. It provides a free, lightweight, and highly compatible alternative for everyday spreadsheet and data analysis needs.

  1. 1. Download WPS Office: Visit the official WPS website and download the free installation package.
  2. 2. Install the Software: Run the installer and follow the simple on-screen instructions to complete the setup.
  3. 3. Open Your Spreadsheet: Launch WPS Spreadsheets and open your .xlsx files to start analyzing your data instantly.
Free and lightweight office suiteHigh compatibility with Microsoft Excel formats (.xlsx, .xls)Built-in PivotTable tools for standard data analysisFamiliar user interface for quick and easy migration
microsoft office alternative - wps office

Frequently Asked Questions

Why do I get 'Error 5: Invalid procedure call' with PivotFilters.Add?

You cannot use the PivotFilters.Add or Add2 methods on a page filter (Report Filter) within a PivotTable. These methods are reserved for row and column fields. For page filters, you must define the CurrentPage property directly.

What is an OLAP member unique name?

In OLAP PivotTables, a unique name is the precise MDX string that identifies a specific data point within a hierarchy, such as [Date].[Year].&[2023]. Standard strings like '2023' will fail because they lack this structural context.

How can I filter multiple dates in an OLAP PivotTable using VBA?

To filter multiple dates, ensure the PivotField is configured correctly, clear the existing filter using ClearAllFilters, and then iterate through the PivotItems to set their Visible property to True or pass an array to the VisibleItemsList property.