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, and 2016.
Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!
Filtering is a great asset when you need to get a handle on a subset of your data. Excel even makes it easy to copy the ...
Discover MoreWhen you filter data in a worksheet, Excel also allows you to apply sorting orders to that data. Here is a ...
Discover MoreIf you have a large number of data records, each with an associated date, you might want to filter that data so you see ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2020-11-25 03:56:08
Philip
My expectation would be that if this is an action that's needed regularly in a certain workbook, setting up a custom view for that scenario is the most straightforward solution (no need to change the file type from xlsx to xlsm for example, no need to change any security settings etc. ...)
2016-05-16 10:44:57
Gary Lundblad
The Remove Filters macro would be great for me, but it doesn't seem to be working.
Thank you!
Gary
2016-05-14 08:39:50
Dave
Both macros don't work for me?
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 © 2021 Sharon Parq Associates, Inc.
Comments