Hi Jan
I'm Anna and I'd be happy to help you with your question. In this Forum, we are Microsoft consumers just like yourself.
The CurrentPage property is used to filter a pivot field based on a specific item or items within that field. However, it is not designed to work with date fields. Instead, you can use the PivotField.PivotFilters.Add method to filter a pivot field based on a date range or specific date values. This method allows you to specify the type of filter (e.g. "greater than or equal to", "between", etc.) and the filter value(s) to use.
For example, to filter a pivot field called "Fact.datum (Jaar)" to show only data for the year 2022, you could use the following code:
filterVeldBtwVerkopen.PivotFilters.Add Type:=xlFilterValues, Value1:="2022"
You could also use PivotField.ClearAllFilters before adding the new filter to ensure that any existing filters are removed.
Alternatively, you can use a calculated field to show only the specific year using the filter of that calculated field.
It's worth noting that the property CurrentPage is not designed for date fields and it will give you an error when trying to apply it on a date field, that's why you are getting the error message you are seeing.
I hope this helps ;-), let me know if this is contrary to what you need, I would still be helpful to answer more of your questions.
Best Regards,
Anna
Give back to the community. Help the next person with this problem by indicating whether this answer solved your problem. Click Yes or No at the bottom.