VBA - Clear Autofilter settings from only specific columns

pliskers

Active Member
Joined
Sep 26, 2002
Messages
461
Office Version
  1. 2016
Platform
  1. Windows
I have a worksheet with a table and slicers that filter on geographical criteria. There are some macros that also filter the numerical fields. I would like the selection of any of the macros to clear the filter selections from the numerical columns (11-34), but leave the filters intact on the geographical columns (1-10).

I initially used the ShowAllData command but then realized it was clearing the geographical selections as well.

How can I clear only the filtering selections in columns 11-34?

Many thanks in advance!
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
How about:

VBA Code:
Sub Macro1()
  Dim i As Long
  Application.ScreenUpdating = False
  For i = 11 To 34
    ActiveSheet.Range("A:AH").AutoFilter Field:=i
  Next
End Sub
 
Upvote 0
Very similar to DanteAmor's solution:
VBA Code:
Sub ConceptForPartialClear()
    Dim FilterRange As Range
    Dim I As Long
   
    With ActiveSheet
        'Assume Filter Range is 100 rows x 34 columns.
        'Assume all colums in this range have data and are filtered
        Set FilterRange = .Range("A1").Resize(100, 34)
        Debug.Print FilterRange.Address
       
        If .AutoFilterMode Then
            For I = 1 To 34
                Select Case I
                    Case 11 To 34
                        'Clear filter
                        FilterRange.AutoFilter Field:=I 'clear filter in single column
                End Select
            Next I
        End If
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,789
Messages
6,121,590
Members
449,039
Latest member
Arbind kumar

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