Filtering VBA Code Problem

sanantonio

Board Regular
Joined
Oct 26, 2021
Messages
124
Office Version
  1. 365
Platform
  1. Windows
Howdy, sorry to queries in one day...

VBA Code:
Sub filter2()
'
' filter2 Macro
'

'

    Sheets("Sheet 1").Select
    On Error Resume Next
    ActiveSheet.PivotTables("PivPOLevel").PivotSelect "Transfer[All]", xlLabelOnly _
        , True
        On Error Resume Next
    Range("G8").Select
    On Error Resume Next
    ActiveSheet.PivotTables("PivPOLevel").ClearAllFilters
    On Error Resume Next
    Sheets("Sheet 2").Select
    Range("B3").Select
    ActiveSheet.PivotTables("PivSummary").ClearAllFilters
    Sheets("Sheet 1").Select
    ActiveSheet.PivotTables("PivPOLevel").PivotFields("997 Exception?"). _
        ClearAllFilters
    ActiveSheet.PivotTables("PivPOLevel").PivotFields("997 Exception?"). _
        CurrentPage = "X"
    ActiveSheet.PivotTables("PivPOLevel").PivotFields("PGI description"). _
        CurrentPage = "(All)"
    With ActiveSheet.PivotTables("PivPOLevel").PivotFields("PGI description")
        .PivotItems("").Visible = False
        .PivotItems("(blank)").Visible = False
        .PivotItems("30").Visible = False
        .PivotItems("00").Visible = False
        .PivotItems("10").Visible = False
        .PivotItems("70").Visible = False
        .PivotItems("20").Visible = False
        .PivotItems("32").Visible = False
    End With
    ActiveSheet.PivotTables("PivPOLevel").PivotFields("PGI description"). _
        EnableMultiplePageItems = True
    ActiveSheet.PivotTables("PivPOLevel").PivotFields("DMK").ClearAllFilters
    ActiveSheet.PivotTables("PivPOLevel").PivotFields("DMK").CurrentPage = "Z1"
    With ActiveSheet.PivotTables("PivPOLevel").PivotFields("Supplier")
        .PivotItems("30004142").Visible = False
    End With
    Sheets("Sheet 2").Select
    ActiveSheet.PivotTables("PivSummary").PivotFields("Vendor ").CurrentPage = _
        "(All)"
    With ActiveSheet.PivotTables("PivSummary").PivotFields("Vendor ")
        .PivotItems("SUPPLIER 1").Visible = False
    End With
    ActiveSheet.PivotTables("PivSummary").PivotFields("PGI Desc.").CurrentPage = _
        "(All)"
    With ActiveSheet.PivotTables("PivSummary").PivotFields("PGI Desc.")
        .PivotItems("(blank)").Visible = False
        .PivotItems("30").Visible = False
    End With
    ActiveSheet.PivotTables("PivSummary").PivotFields("DMK").ClearAllFilters
    ActiveSheet.PivotTables("PivSummary").PivotFields("DMK").CurrentPage = "Z1"
    ActiveSheet.PivotTables("PivSummary").PivotFields("Comments on Open POs"). _
        CurrentPage = "(All)"
    With ActiveSheet.PivotTables("PivSummary").PivotFields("Comments on Open POs")
        .PivotItems( _
        "PO has already been rolled today. Please reach out if you cannot find the associated PO." _
        ).Visible = False
    End With
    Sheets("Setup").Select
End Sub

I did all of this using the macro record function. The issue I'm having is with the final filter. The entries into this will change all the time, apart from the default error message "PO has already been rolled today. Please reach out if you cannot find the associated PO."

I need that last filter to always filter OUT anything with this statement, regardless of whatever else might appear in the filter.

I thought putting <> between the open " and the first word did this but it doesn't seem to work. Currently when I run the macro it happily filters everything else and leaves this one untouched.

Thanks in advance for any help!
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Bump :-)

Can anyone save me? Maybe I can provide more information?
 
Upvote 0
Hi All. Circling back to this issue.

I just need the code for filtering a specific value OUT of a pivot filter and leaving all the rest in regardless of what other values come in.

The internet seems to suggest putting <> between the opening " and the value should work but all the references I find online are only talking about a normal table filter, this method doesn't seem to work in a pivot filter; at least not in my pivot :-/
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top