How to Unhide All Sheets Using VBA (With Example)


You can use the Visible property in VBA to unhide a sheet in an Excel workbook.

To unhide all sheets in a workbook, you can use the following syntax:

Sub UnhideAllSheets()

Dim ws As Worksheet

    For Each ws In Worksheets
        ws.Visible = True
    Next ws

End Sub

By using a simple For Each loop and specifying Visible = True, we tell Excel to make all sheets in the workbook unhidden.

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

Example: How to Unhide All Sheets Using VBA

Suppose we have an Excel workbook with four sheets:

Now suppose we right click on Sheet4 and then click Hide:

Suppose we repeat this process with Sheet2 so that the only visible sheets are now Sheet1 and Sheet3.

Suppose we would like to use VBA to unhide all sheets in the workbook.

We can create the following macro to do so:

Sub UnhideAllSheets()

Dim ws As Worksheet

    For Each ws In Worksheets
        ws.Visible = True
    Next ws

End Sub

Once we run this macro, all sheets in the workbook will be unhidden:

Note: You can find the complete documentation for the Visible 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 Find Last Used Column
VBA: How to Freeze Panes

Featured Posts

Leave a Reply

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