How to Unhide All Rows Using VBA (With Example)


You can use the Hidden property in VBA to unhide a row in a given sheet.

To unhide all rows in a given sheet, you can use the following syntax:

Sub UnhideAllRows()

Rows.EntireRow.Hidden = False

End Sub

By using the Hidden property and specifying a value of False, we tell Excel to unhide all rows in the current sheet.

The following example shows how to use this syntax in practice.

Example: How to Unhide All Rows Using VBA

Suppose we have an Excel sheet that contains information about various basketball players:

Now suppose we right click on row 3 and then click Hide:

Suppose we repeat this process for rows 7 and 8 so that we have several rows that are now hidden in our sheet:

Now suppose we would like to use VBA to unhide all rows in this sheet.

We can create the following macro to do so:

Sub UnhideAllRows()

Rows.EntireRow.Hidden = False

End Sub

Once we run this macro, all rows will be unhidden:

Notice that all rows from our original dataset are visible once again.

Note that if you’d like to unhide all rows in all sheets of an Excel workbook, you could create the following macro to do so:

Sub UnhideAllRowsAllSheets()

Dim ws As Worksheet

    For Each ws In Worksheets
        ws.Rows.EntireRow.Hidden = False
    Next ws

End Sub

By using a simple For Each loop, we can loop through each sheet in our workbook and unhide all rows in each sheet.

Note: You can find the complete documentation for the Hidden property in VBA here.

Additional Resources

The following tutorials explain how to perform other common tasks in VBA:

VBA: How to Find Last Used Row
VBA: How to Unhide All Sheets
VBA: How to Freeze Panes

Leave a Reply

Your email address will not be published. Required fields are marked *