• 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.

VBA changing Pivot Table Dates

yan nian

New Member
I've encountered a problem in changing Pivot Table Dates as i am not familiar with this, but i think i almost got it, i will attach the printscreen in below to illustrate my issue.

Problems:
1) The first pivot table date selection is in the format as shown per below.
12-Dec-17
2) My button will be executing a function where it will set all the pivotfield's date in different pivot table according to PivotTable1.

3) My VBA code written can only set all the pivot table to the date format as shown per below. (i did attempt to solve this by using custom cells dd-mmm-yy, but it's not working). My code did work, but only shows date format as below, but the data in pivot table is not updated to the date accordingly( after pressing the button).
12/12/2017

4) I have to manually change the date to 12-Dec-17 for all the date in the following pivot tables, so that all the pivot tables can get all the data from the date 12-Dec-17. Currently i failed to do so.

_____________________________________________________________

First of all, i will attach the button code

Code:
Sub ChgFilter()
DateChoose = ActiveSheet.PivotTables("PivotTable1").PivotFields("Date").CurrentPage
ForEach PT In ActiveSheet.PivotTables

PT.PivotFields("Date").CurrentPage =CDate(DateChoose)
Next
EndSub


Secondly, Pictures will be attached with explanations
  1. Date must be selected, I will attach the date dropdown list data on the next printscreen.
  2. Press the button to change the date for other pivot table as i have more than 1 pivot table in below.
 

Attachments

  • PivotTables.JPG
    PivotTables.JPG
    71.4 KB · Views: 3
  • PivotTables2.JPG
    PivotTables2.JPG
    61.1 KB · Views: 3
Upload sample workbook please. Picture is worth a thousand words. But sample workbook is worth a thousand pictures ;)
 
Dear @Chihiro
I've uploaded the files, the printscreen i've shown in my post is on the 3rd worksheet. Thank you
 

Attachments

  • PIVOTTABLE1.xls
    889 KB · Views: 0
Dear Luke M
I am sorry for that, that's my post as well, but currently there are no solutions for this and i am seeking for help, noted about this, next time i will be providing links to those thread that i am posting. Sorry once again and thank you for reminding me regarding this.
 
Last edited:
Back
Top