简体   繁体   中英

excel real time refresh of filter

In my Pivot Table in excel, I have a field List about the due date of some reports.

For example, 10/5/2016

My problem is, every day I have to choose the date so that I can see the report code, I don't want it to be this. What I want is, everyday I open the excel, the filter will automatically change from 10/5/2016 to 11/5/2016.

What function / VBA should I use?

Helps

If you want a VBA solution, add the following to the ThisWorkbook code.

Private Sub Workbook_Open()

Dim tDay As Date, pf As PivotField
tDay = Date

    Set pf = Sheets("name of worksheet").PivotTables("pivot table name").PivotFields("insert the name of your filter here")

    pf.ClearAllFilters
    pf.CurrentPage = tDay

End Sub

Change the sheet name, pivot table name and the name of the filter.

If you need to do more VBA manipulation of pivot tables I suggest reading the following http://www.thespreadsheetguru.com/blog/2014/9/27/vba-guide-excel-pivot-tables .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM