How can I use VBA to unhide all rows in my spreadsheet?

VBA, or Visual Basic for Applications, is a programming language that can be used to automate tasks in Microsoft Excel. One useful function of VBA is the ability to unhide all rows in a spreadsheet. This can be done by utilizing the “Rows” property, which allows the user to access and manipulate all rows in a worksheet. By using a loop and setting the “Hidden” property to “False”, all hidden rows can be unhidden. This can be a time-saving and efficient way to manage large amounts of data in an Excel spreadsheet.

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 = FalseEnd 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 = FalseEnd Sub

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

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 = FalseNext 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 .

Additional Resources

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

x