Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Detecting Hidden Rows.

Detecting Hidden Rows

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


4

Jesse has a large worksheet that may contain hidden rows. He wonders if there is a way to find out if there are hidden rows in the worksheet other than by looking down the many rows to see what's missing. If he unhides all the hidden rows, he still won't be able to tell what, if any, rows may have been hidden.

One way you can identify hidden rows is to follow these general steps:

  1. In a column that has nothing in it, select all the cells that will cover the area you want to check. (You can select the entire column, if you desire, but that may be overkill.)
  2. Press Alt+; (that's a semicolon). Excel selects only the unhidden cells in the selected range.
  3. Press X (or some other viewable character) and press Ctrl+Enter. This puts the character (X) into all the visible cells.

Unhide all the rows, and you'll be able to easily see which cells in that column don't have the character (X) in them. These are the rows that were previously hidden. You could also, if desired, use the same general approach, but after step 2 (instead of step 3) you could apply some pattern or color to the cells. Once you unhide all the rows, those cells without any pattern or color are the ones that were previously in hidden rows.

If you don't want to unhide rows at all, perhaps the best way to find out the information is to use a macro. The following simple macro steps through the first 1,000 rows of a worksheet and then lists, in a message box, the rows that are hidden.

Sub ShowRows()
    Dim rng As Range
    Dim c As Range
    Dim sTemp As String

    Set rng = Range("A1:A1000")
    sTemp = ""

    For Each c in rng
        If c.EntireRow.Hidden Then
            sTemp = sTemp & "Row " & c.Row & vbCrLf
        End If
    Next c

    If sTemp > "" Then
        sTemp = "The following rows are hidden:" & vbCrLf & _
          vbCrLf & sTemp
        MsgBox sTemp
    Else
        MsgBox "There are no hidden rows"
    End If
End Sub

Note that the heart of the macro—where it determines whether a row is hidden or not—is in checking the Hidden property of the EntireRow object. If this property is True, then the row is 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 (12217) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Excel here: Detecting Hidden Rows.

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

Quickly Dumping Array Contents

Variable arrays are used quite often in macros. If you use an array once in your macro and then need to reuse it for ...

Discover More

Collating Copies

If you are printing more than one copy of a multi-page document, it would be great if Word could print them in complete ...

Discover More

Changing Text Case

Word provides a built-in shortcut to change the case of a text selection. Understanding how that shortcut works (and the ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (ribbon)

Automatic Row Height for Wrapped Text

When you format a cell so that the information within it can wrap to multiple lines, you may be surprised if Excel ...

Discover More

Adjusting Row Height for a Number of Worksheets

Adjusting the height of a row or range of rows is relatively easy in Excel. How do you adjust the height of those same ...

Discover More

Hiding a Huge Number of Rows

Need to hide a large number of rows? It's easy to do if you combine a few keyboard shortcuts. Here are several techniques ...

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 8 - 3?

2022-07-31 11:23:11

J. Woolley

It should be noted that ListHiddenRowsCols (see my previous comment) must be used with newer versions of Excel (2021+) that support dynamic array functions. It doesn't work with My Excel Toolbox's SpillArray function in a cell formula; I don't know why yet. However, it could by called by a macro (Sub) with results in a MsgBox or posted to a worksheet.


2022-07-31 10:30:43

J. Woolley

In the VBA code of my previous comment for the simplified version of ListHiddenRowsCols, this statement
    With ActiveSheet
should be replaced by
    With Application.Caller.Worksheet
This assumes the function will be used as a UDF in a cell formula.


2022-07-30 11:27:55

J. Woolley

My Excel Toolbox includes the following function to return a list of hidden rows and columns as a dynamic array:
=ListHiddenRowsCols([AllSheets])
If AllSheets is FALSE (default), only the current worksheet will be evaluated; if TRUE, all worksheets in the workbook will be included.
This function considers the "used" range from cell A1 to the last non-blank cell or the last formatted blank cell (Ctrl+End). It normally returns hidden rows beyond the used range, but it returns hidden columns beyond the used range only if they were adjacent to the used range before they were hidden; such columns are added to the used range even if they are subsequently unhidden. The used range is reset when the workbook is closed and reopened.
Here is a simplified version of the function:

Public Function ListHiddenRowsCols() As String()
    Dim A() As String, B As String, C As Collection, n As Long
    Application.Volatile
    B = "[" & ActiveWorkbook.Name & "]"
    Set C = New Collection
    C.Add "Hidden Rows/Cols"
    With ActiveSheet
        ListHiddenRowsCols_Do B, .Rows, _
            (.UsedRange.Row + .UsedRange.Rows.Count), C
        ListHiddenRowsCols_Do B, .Columns, _
            (.UsedRange.Column + .UsedRange.Columns.Count), C
    End With
    If C.Count = 1 Then C.Add "None"
    ReDim A(1 To C.Count, 1 To 1)
    For n = 1 To C.Count
        A(n, 1) = C(n)
    Next n
    ListHiddenRowsCols = A
End Function

Private Sub ListHiddenRowsCols_Do(Book As String, _
    Obj As Object, Nbr As Long, ByRef C As Collection)
    Dim nBeg As Long, nEnd As Long, n As Long
    nBeg = 0
    For n = 1 To Nbr
        If Obj(n).Hidden Then
            If nBeg = 0 Then
                nBeg = n
                nEnd = n
            ElseIf n = nEnd + 1 Then
                nEnd = n
            End If
        ElseIf nBeg > 0 Then
            C.Add Replace(Application.Range(Obj(nBeg), _
                Obj(nEnd)).Address(External:=True), _
                Book, "", 1, 1)
            nBeg = 0
        End If
    Next n
End Sub

See https://sites.google.com/view/MyExcelToolbox/


2022-07-25 15:42:24

Mike D.

I noticed that when you put the color in and you still have it selected with the ALT+; there are breaks in the color where the hidden rows are located. Very helpful for finding the hidden without un-hiding the rows.

I also adapted the code to do the same for hidden columns and then both columns and rows.

Nice lesson, Thanks


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.