VBA: How to Unhide One or Multiple Sheets

Yash Gaur Add Comment

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.
VBA : Unhide a single sheet
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.
Related Posts
Spread the Word!
Share
About Author:
Yash Gaur

Yash is pursuing an MBA in Finance with a keen interest in analytics. He enjoys working with data and leveraging his research and analytical skills to generate valuable insights.

Post Comment 0 Response to "VBA: How to Unhide One or Multiple Sheets"
Next → ← Prev