largeselection
Active Member
- Joined
- Aug 4, 2008
- Messages
- 358
Hello,
I'm having some difficulty wrapping my mind around how is best to structure this so hopefully someone can point me in the right direction or send me a link to some useful information.
Basically I want to create some code which will change the elements in a pivot table filter- So I have say 200 players and I currently have a pivot table which displays information and "PLAYER" is a field in the filter. I want to be able to display only the information in the pivot table for say 25 players only so currently I can go into the filter and manually select the 25 I want to see and deselect everyone else. The issue is that I may want to see different groups and I'd like it to be faster than that manual work. So I thought it might be possible to have the filter adjust programatticaly based on a list of cells- that way I can just paste the PLAYER #s I want to see in a range and have the table filter without having to click each one individually.
So I know at some point I will use:
in order to do the actual filtering so what I need help with is how to fill the array.
All the elements in the array take the form "[PLAYER].[PLAYER].&[###]" so if I record while I select two players the resulting code is:
so if I have a range of cells (A1:Axxx) how can I have it create an array that basically says set the Array = "[PLAYER].[PLAYER].&[A1]", "[PLAYER].[PLAYER].&[A2]", "[PLAYER].[PLAYER].&[Axxx]", from A1 until the next cell in column A is blank?
Sorry for the long post, but I wanted to include all the details. TIA for any help/direction.
I'm having some difficulty wrapping my mind around how is best to structure this so hopefully someone can point me in the right direction or send me a link to some useful information.
Basically I want to create some code which will change the elements in a pivot table filter- So I have say 200 players and I currently have a pivot table which displays information and "PLAYER" is a field in the filter. I want to be able to display only the information in the pivot table for say 25 players only so currently I can go into the filter and manually select the 25 I want to see and deselect everyone else. The issue is that I may want to see different groups and I'd like it to be faster than that manual work. So I thought it might be possible to have the filter adjust programatticaly based on a list of cells- that way I can just paste the PLAYER #s I want to see in a range and have the table filter without having to click each one individually.
So I know at some point I will use:
Code:
ActiveSheet.PivotTables("DB1").PivotFields( _
"[PLAYER].[PLAYER].[PLAYER]").VisibleItemsList = Array(........
in order to do the actual filtering so what I need help with is how to fill the array.
All the elements in the array take the form "[PLAYER].[PLAYER].&[###]" so if I record while I select two players the resulting code is:
Code:
...VisibleItemsList = Array("[PLAYER].[PLAYER].&[471]", "[PLAYER].[PLAYER].&[472]")
so if I have a range of cells (A1:Axxx) how can I have it create an array that basically says set the Array = "[PLAYER].[PLAYER].&[A1]", "[PLAYER].[PLAYER].&[A2]", "[PLAYER].[PLAYER].&[Axxx]", from A1 until the next cell in column A is blank?
Sorry for the long post, but I wanted to include all the details. TIA for any help/direction.