Fix Excel VBA PivotField.CurrentPage Error for Date Filters
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.

- 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 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.
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.
Ensure that the target PivotField is placed in the Report Filter area of your PivotTable before executing the script.
Find the correct OLAP hierarchy and member key. For example, use a format like [Verkopen].[Fact.datum (Jaar)].&[2023] instead of simply "2023".
Assign the exact member unique name string directly to the PivotField.CurrentPage property in your VBA code.

Avoid PivotFilters.Add for Page Filters
Resolve runtime errors by avoiding the Add or Add2 methods, which are inherently unsupported for page filters in Excel.
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. Download WPS Office: Visit the official WPS website and download the free installation package.
- 2. Install the Software: Run the installer and follow the simple on-screen instructions to complete the setup.
- 3. Open Your Spreadsheet: Launch WPS Spreadsheets and open your .xlsx files to start analyzing your data instantly.

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.




