Rob has a workbook that contains multiple worksheets. He would like to know the easiest way to remove filters and unhide rows and columns in all the worksheets at once.
One would think that it would be possible to do this manually by building a "selection set" of all the worksheets you want to affect, and then removing filters. While you can use this approach for unhiding rows, you cannot affect filters—once you select more than a single worksheet, the Filter tool (on the Data tab of the ribbon) is no longer selectable.
This means that you must use a macro to do the work—unless you want to remove filters one worksheet at a time. Here is a short little macro that will remove any filters applied to any worksheets in the workbook:
Sub RemoveFilters()
Dim wks As Worksheet
Application.ScreenUpdating = False
For Each wks In ThisWorkbook.Worksheets
If wks.AutoFilterMode Then wks.AutoFilterMode = False
Next wks
Application.ScreenUpdating = True
End Sub
If the hidden rows and columns are a result of the filters you applied, those rows and columns should be visible after removing all the filters. If there are other rows and columns that are manually hidden and that you want displayed, you can use the following version of the macro:
Sub RemoveFiltersUnhide()
Dim wks As Worksheet
Application.ScreenUpdating = False
For Each wks In ThisWorkbook.Worksheets
With wks
If .AutoFilterMode Then .AutoFilterMode = False
.Rows.Hidden = False
.Columns.Hidden = False
End With
Next wks
Application.ScreenUpdating = True
End Sub
This version removes filters and then unhides any rows and columns previously hidden.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3036) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, 2021, and Excel in Microsoft 365.
Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel Data Analysis and Business Modeling today!
The filtering capabilities of Excel can come in handy for zeroing in on the data you want to work with. When your data ...
Discover MoreFiltering can help you make sense of large data sets. If you want to change the values in a lot of cells that are ...
Discover MoreYou can use Excel to keep what is essentially a small, simple database of information. Getting information from the ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2022-10-31 17:03:23
Dave Bonin
Mr./Ms. Woolley,
Your suggestion is obviously correct.
That said, I've often seen VBA code that tests for the current condition and only makes a change if the current condition is not what we want.
I'm not sure why that is. Perhaps it's left over from when processors were not as powerful as they are now. In that case, the programmer might avoid making a change that was redundant. Maybe it's a universal best practice that is most powerful when calling a macro that might take a while to run. Perhaps it's a best practice that was much more common with other languages that crept into common VBA use.
Would you have any thoughts on this?
2022-10-29 10:18:10
J. Woolley
Obviously this line
If wks.AutoFilterMode Then wks.AutoFilterMode = False
can be changed to simply
wks.AutoFilterMode = False
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2026 Sharon Parq Associates, Inc.
Comments