rvdb Posted January 21, 2019 Posted January 21, 2019 Hello, In a part of my Autoit script, I need to change a filter on a pivot table ("PivotTable2") on a sheet ("absenteïsme") in Excel. This filter has to be set to "This Month" or "Last Month", (see image in attachment), depending on other criteria. I have recorded the action to set the filter to "This Month" by a macro and the VBA code generated is: ActiveSheet.PivotTables("PivotTable1").PivotFields("Datum").ClearAllFilters ActiveSheet.PivotTables("PivotTable1").PivotFields("Datum").PivotFilters.Add2 _ Type:=xlDateThisMonth I figured out how to translate the first line to Autoit: $oExcel.Application.Sheets("absenteïsme").PivotTables("PivotTable2").PivotFields("Datum").ClearAllFilters But I can't figure out how to set the next part of the code in Autoit. Can someone help me to translate the rest of the code to AutoIt?
Subz Posted January 21, 2019 Posted January 21, 2019 The following should work: ;~ https://docs.microsoft.com/en-us/office/vba/api/excel.xlpivotfiltertype Global Const $xlDateThisMonth = 44 $oExcel.Application.Sheets("PivotTable1").PivotTables("PivotTable1").PivotFields("Datum").ClearAllFilters $oExcel.Application.Sheets("PivotTable1").PivotTables("PivotTable1").PivotFields("Datum").PivotFilters.Add2($xlDateThisMonth)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now