ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Turn Filters On and Off (https://www.excelbanter.com/excel-programming/373112-turn-filters-off.html)

Phil H[_2_]

Turn Filters On and Off
 
The below code successfully adds AutoFilters to the selection. How do I
remove the AutoFilters? Tried recording a macro but the code is the same as
for adding filters.

Private Sub CommandButton4_Click()
'Command Button: "Add Filters"
Application.ScreenUpdating = False
Range("B3:I3").Select
Selection.AutoFilter
Application.ScreenUpdating = True
End Sub

Kevin B

Turn Filters On and Off
 
The same line that turn AutoFilter on is the same command that will turn them
off:

Selection.AutoFilter

--
Kevin Backmann


"Phil H" wrote:

The below code successfully adds AutoFilters to the selection. How do I
remove the AutoFilters? Tried recording a macro but the code is the same as
for adding filters.

Private Sub CommandButton4_Click()
'Command Button: "Add Filters"
Application.ScreenUpdating = False
Range("B3:I3").Select
Selection.AutoFilter
Application.ScreenUpdating = True
End Sub


Tom Ogilvy

Turn Filters On and Off
 
You can also use

Activesheet.Autofiltermode = False

--
Regards,
Tom Ogilvy


"Phil H" wrote:

The below code successfully adds AutoFilters to the selection. How do I
remove the AutoFilters? Tried recording a macro but the code is the same as
for adding filters.

Private Sub CommandButton4_Click()
'Command Button: "Add Filters"
Application.ScreenUpdating = False
Range("B3:I3").Select
Selection.AutoFilter
Application.ScreenUpdating = True
End Sub



All times are GMT +1. The time now is 11:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com