Table of Contents
VBA, or Visual Basic for Applications, is a programming language that can be used to automate tasks in Microsoft Excel. One useful application of VBA is to unhide all sheets in an Excel workbook. This can be done by writing a simple code that loops through all the sheets in the workbook and changes their visibility property from “hidden” to “visible”. This allows users to quickly unhide multiple sheets at once without having to manually unhide each one individually. By utilizing VBA, users can save time and improve efficiency in managing and organizing their Excel workbooks.
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 = TrueNext 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 = TrueNext ws
End Sub
Once we run this macro, all sheets in the workbook will be unhidden:
Additional Resources
The following tutorials explain how to perform other common tasks in VBA: