This tutorial explains how to unhide sheets in Excel using VBA.
Syntax to Unhide a Sheet
The following VBA code unhides the sheet named “Sheet2” in Excel.
Sub UnhideMultipleSheets() ThisWorkbook.Sheets("Sheet2").Visible = True End Sub
You can download the following dataset to practice.
1. Unhide a Single Sheet
Let’s take a sample dataset and try to unhide Sheet4. The following code unhides “Sheet4” in the given workbook:
Sub UnhideSheet4() Dim ws As Worksheet Set ws = ThisWorkbook.Sheets("Sheet4") ws.Visible = True End Sub
Press Run or F5 to run the above code.
2. Unhide Multiple Sheets
Let’s try to unhide Sheet2, Sheet3, Sheet4, Sheet5 and Sheet6.
Sub UnhideMultipleSheet() Dim ws As Worksheet Dim element As Variant For Each element In Array("Sheet2", "Sheet3", "Sheet4", "Sheet5", "Sheet6") ws.Visible = True Next element End Sub
Press Run or F5 to run the above code.
3. Unhide All Sheets
In this case we will try to unhide all sheets in Excel using VBA.
Sub UnhideAllSheets() Dim ws As Worksheet For Each ws In ThisWorkbook.Sheets ws.Visible = True Next ws End Sub
Press Run or F5 to run the above code.
Read MoreListenData