Link to home
Start Free TrialLog in
Avatar of Euro5
Euro5Flag for United States of America

asked on

vba autofilter in row 4

I need to remove a filter that is applied to a table.
The problem is, the filter is in row 4, not row 1.
When I try to use
Selection.AutoFilter

Open in new window

or variation, it just applies the filter to row 1.
I have also tried:
If ActiveSheet.AutoFilterMode Then Cells.AutoFilter

Open in new window


Any ideas?
Avatar of Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj)
Flag of India image

Try this.....

If ActiveSheet.FilterMode Then ActiveSheet.ShowAllData

Open in new window

Hi,

Please try below, change Column C for Last Row and change the range for rngFilter
Sub ResetFilter()
    Dim Ws As Worksheet
    Dim LR As Long
    Dim RngFilter As Range
    Set Ws = ActiveSheet
    Ws.Cells.AutoFilter
    LR = Ws.Range("C" & Rows.Count).End(xlUp).Row
    Set RngFilter = Ws.Range("C4:L" & LR)
    RngFilter.AutoFilter Field:=3, Criteria1:="<>""", Operator:=xlOr
    
End Sub

Open in new window

did you try

ActiveSheet.ShowAllData
Avatar of Euro5

ASKER

Neeraj,
Didn't work. It removes the filter if it is in row 1, but the filter is still on the table.
I tried to recording a macro, but that didn't work either. Not sure what I'm missing...
ASKER CERTIFIED SOLUTION
Avatar of Shums Faruk
Shums Faruk
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Do you want to remove the filter from the sheet?
If so, you may try this.....

ActiveSheet.AutoFilterMode = False

Open in new window