VBA to clear a filter

Guitarmageddon

Board Regular
Joined
Dec 22, 2014
Messages
159
Hello all....should be a simple one. Im working with some VBA i made forever ago and seem to have forgotten some of the stuff Ive learned.

Several steps in, I have a command to filter one of my columns, shown here. Filtering a filter dropdown (row 1 of sheet has filters) to show only the rows with "STOW" value

VBA Code:
With ActiveWorkbook.Worksheets("Page1").AutoFilter.Sort
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
        ActiveSheet.Range("$A$2:$AY$" & Range("A" & Rows.Count).End(xlUp).Row).AutoFilter Field:=5, Criteria1:="STOW" _
        , Operator:=xlAnd
    End With


I do a few sorts on other columns in the meantime. When I go with what I thought was the command to clear the filter from that "STOW" column, it doesnt work.... I want to keep my filter dropdowns on row 1, but just show all the values again. Help?

This is the one I used elsewhere in the code, and it worked. Maybe Im missing some of the other context.
VBA Code:
ActiveWorkbook.Worksheets("Page1").AutoFilter.Sort.SortFields.Clear
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Just an FYI that will crash if there is no filter applied or autofilter is not turned on. Safer would be
VBA Code:
    If Worksheets("Page1").FilterMode = True Then
        Worksheets("Page1").ShowAllData
    End If
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,195
Members
449,072
Latest member
DW Draft

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