AutoFilter - Hide particular category

tlc53

Active Member
Joined
Jul 26, 2018
Messages
399
Hi there,
Can someone help me fix this code please? Step 6 is the bit that's not quite right. Instead of showing the AutoFilter categories selected, I want it to hide category "ZZZSpare".
Thank you!

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

'1) Select table "Member_Table_Subtotal"
    Application.Goto Reference:="Member_Table_Subtotal"
    
'2) Subtotal = Remove all
    Selection.RemoveSubtotal
    
'3) Remove filters
    Selection.AutoFilter
    
'4) Select table "Member_Table"
    Application.Goto Reference:="Member_Table"
    
'5) Sort table by "Team Member" then by "Location"
    ActiveWorkbook.Worksheets("Stocktake Print Sheets").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Stocktake Print Sheets").Sort.SortFields.Add2 Key _
        :=Range("D6:D122"), SortOn:=xlSortOnValues, Order:=xlAscending, _
        DataOption:=xlSortNormal
    ActiveWorkbook.Worksheets("Stocktake Print Sheets").Sort.SortFields.Add2 Key _
        :=Range("C6:C122"), SortOn:=xlSortOnValues, Order:=xlAscending, _
        DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Stocktake Print Sheets").Sort
        .SetRange Range("A5:G122")
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    
'6) Add filter, Under title "Location" hide "ZZZSpare"
    Selection.AutoFilter
    ActiveSheet.Range("$A$5:$G$122").AutoFilter Field:=3, Criteria1:=Array( _
        "Kitchen", "Lundia", "Stationery", "Storage Room", "Toilet"), Operator:= _
        xlFilterValues
 
 '7) Add subtotals
    Selection.Subtotal GroupBy:=4, Function:=xlCount, TotalList:=Array(1), _
        Replace:=False, PageBreaks:=True, SummaryBelowData:=True
    ActiveWindow.SmallScroll Down:=-24
    
 '8) Go to top of table
    Range("A5").Select
End Sub
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Try this
VBA Code:
'6) Add filter, Under title "Location" hide "ZZZSpare"
    Range("$A$5:$G$122").AutoFilter Field:=3, Criteria1:="<>ZZZSpare"

'7) Add subtotals
 
Upvote 0
Solution
You're welcome. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,214,520
Messages
6,120,013
Members
448,935
Latest member
ijat

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