Removing Filters and Unhiding Rows and Columns on Multiple Worksheets

Written by Allen Wyatt (last updated October 29, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


2

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:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3036) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Understanding DATE Field Formatting

One of the most commonly used fields is the DATE field. You can specify how the DATE field displays the current date by ...

Discover More

Incrementing Months in Dates

Excel can easily store dates. If you want to increment a date by one month, there are a number of ways you can accomplish ...

Discover More

Separating a Date into Component Columns

Do you need a way to split dates out into the individual parts that make up that date? This tip provides two easy ways ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Filtering to a Date Range in the Past

If you have a large number of data records, each with an associated date, you might want to filter that data so you see ...

Discover More

Using a Filtered Value in a Formula

Accessing filtering criteria for use in a formula can be a real need for some worksheet designs. Getting to that ...

Discover More

Counting Filtered Rows

The filtering capabilities of Excel are indispensable when working with large sets of data. When you create a filtered ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 6 - 6?

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


This Site

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.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.