PDA

View Full Version : Solved: PIVOT FILTER



Sarfaraz
04-10-2013, 11:34 PM
Dear All,
I have a pivot table G14:I22 in which I like to make two macors

Macro1: Select the values begining with "GP"
Macro2: Select values other than begining with "GP"

I am also attaching sample sheet would be grateful for help

Regards

sassora
04-14-2013, 12:26 AM
The approach I would take here is to record a macro and on the customer column select "label filters", there is an option for "Begins with" and "Does not being with".

Once you have shown both lists then stop macro recording and go to module 1 which will contain the code. Happy to look at the code if you post it to the site.

Sarfaraz
04-18-2013, 02:44 AM
Thanks Sasoora for giving a nice idea. Using you advise I have made following code and it is working fine. For the reference of others I am also attaching the files.


sub Primary()
'
' Primary Macro
'
'
ActiveSheet.PivotTables("PivotTable1").PivotFields("Customer Name"). _
ClearAllFilters
ActiveSheet.PivotTables("PivotTable1").PivotFields("Customer Name"). _
PivotFilters.Add Type:=xlCaptionBeginsWith, Value1:="PK"
Range("A13").Select
End Sub

Sub Secondary()
'
' Secondary Macro
'
'
ActiveSheet.PivotTables("PivotTable1").PivotFields("Customer Name"). _
ClearAllFilters
ActiveSheet.PivotTables("PivotTable1").PivotFields("Customer Name"). _
PivotFilters.Add Type:=xlCaptionDoesNotBeginWith, Value1:="PK"
Range("A13").Select
End Sub

:friends: