This seems like a simple problem, but I've spent hours failing to solve... I'd like to have my pivot table update an existing filter to include all dates this month. I regularly update the data source and this source includes data from year to date. In my pivot table, I only want to see this month's data. So I wrote this:
Dim pvtAOL As PivotTable
Set pvtAOL = ActiveSheet.PivotTables(1)
pvtAOL.TableRange1.Activate
pvtAOL.RefreshTable
pvtAOL.PivotFields("Date").ClearAllFilters
pvtAOL.PivotFields("Date").PivotFilters.Add FilterType:=xlAllDatesInPeriodJuly
If I comment out the last line, everything works. If I try to run it with the last line included, I get the following error:
Run-time error '448':Named argument not found
Open to other fixes / corrections if you see them as I'm new to VBA. thx!
xlDateThisMonth
? Also does excel recognize theDate
PivotField as an actual Date value? Find enumeration here .. if it helps. – Scott HoltzmanType
, but the examples useFilterType
. When you record a macro doing a similar thing, the created code usesType
. Maybe they are synonyms, but it might be worth trying to change FilterType to Type. – YowE3KFilterType
and usingType
gives me a different error:Run-time error 1004: Application-defined or object-defined error
– Kent Sanner