• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

how to select the current date on pivot table 2 using refresh macro?

Jay.pot04

New Member
ActiveSheet.PivotTables("PivotTable2").PivotFields("Date").CurrentPage = _
"8/22/2016"
 

Attachments

  • Copy of IBC Intraday Report_201608 (Aug).xlsm
    615.1 KB · Views: 3
When you refer to Current Date, do you mean Today's date? Your code is working as intended through the Date Filter - i.e. it will reset the Filter to 08/22/2016 - it fails a few lines later on one of your hidden sheets, but I don't think that's your current issue ...
 
Hi David,

yes you are right,I want to filter the current date moving forward. I believe on my coding it will only provide filter for 8/22 only.

______________________________________________________________
Mod edit : thread moved to appropriate forum !
 
Code:
ActiveSheet.PivotTables("PivotTable2").PivotFields("Date").CurrentPage = Date

Date represents today's date in VBA. Do note that you may need format adjustment depending on your set up. For Pivot operation, it will need exact match on literal string and not the value (i.e. 8/23/2016 and not Aug 23, 2016 etc).

Also, it will throw error when and if there is no match found. You may want to code in error handling there.
 
Back
Top