Link to home
Start Free TrialLog in
Avatar of j2jake
j2jake

asked on

change pivot table filter

Hi Experts!

Newbie here in excel VBA. I need to change the pivot table filter when the user chooses which month to display. It should show the trailing 4 months from the chosen month and year and the last year of the chosen month. I have uploaded a sample data.

In the selection sheet, "November" and "2009" is chosen so the pivot table shows 6 month filters. They are "2008-11", "2009-07","2009-08","2009-09","2009-10" and "2009-11".

Thanks so much!
Avatar of j2jake
j2jake

ASKER

forgot to upload the sample file. here it is.
test.xls
Find the attached file...

Joydip
sample.xls
Just change the selection in the Selection sheet and refresh the pivot table.

If you want the no of trailing to be dynamic instead of fixed as 4, that can also be done.

Regards,
Joydip
Avatar of j2jake

ASKER

hi joydip!

thanks so much!

can you explain to me a bit of how this works?

how can you set the trailing to be fixed as 4 or to any number?
Avatar of j2jake

ASKER

hi again!

i got the logic. thanks!

how can you set it up to be fixed as 4?

is there another way to like change the pivot filter using vba? what i really wanted to do is to only have the user interaction through the selection sheet. so after choosing the month and year, the pivot automatically changes without it being refreshed.
Dear i2jake,
>how can you set it up to be fixed as 4?

Find the attached file...

Joydip
sample.xls
ASKER CERTIFIED SOLUTION
Avatar of ghoshsaikat83
ghoshsaikat83

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of j2jake

ASKER

Thanks!