Consulting

Results 1 to 3 of 3

Thread: Solved: PIVOT FILTER

  1. #1
    VBAX Regular
    Joined
    Feb 2013
    Posts
    30
    Location

    Solved: PIVOT FILTER

    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
    Attached Files Attached Files

  2. #2
    VBAX Tutor
    Joined
    Jan 2008
    Posts
    262
    Location
    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.
    sassora

  3. #3
    VBAX Regular
    Joined
    Feb 2013
    Posts
    30
    Location
    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.

    [VBA]
    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

    [/VBA]
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •