How to unhide a hidden Excel sheet using VBA?

To unhide a hidden Excel sheet using VBA, you can write a simple macro to accomplish this. Here’s how you can do it:

   Sub UnhideSheet()
       Dim ws As Worksheet
       ' Loop through each worksheet in the active workbook
       For Each ws In ThisWorkbook.Worksheets
           ' Check if the worksheet is hidden
           If ws.Visible = xlSheetHidden Or ws.Visible = xlSheetVeryHidden Then
               ' Unhide the worksheet
               ws.Visible = xlSheetVisible
           End If
       Next ws
   End Sub
  • Open the VBA Editor:
    • Press `ALT` + `F11` to open the VBA editor in Excel.
  • Insert a New Module:
    • In the VBA editor, go to `Insert` > `Module` to create a new module.
  • Write the VBA Code:
    • Copy and paste the following code into the module window:

This macro will unhide all hidden sheets in the active workbook.

  • Run the Macro:
    • Close the VBA editor and return to Excel.
    • Go to `Developer` > `Macros` or press `ALT` + `F8` to open the Macro dialog box.
    • Select `UnhideSheet` from the list and click `Run`.

This script will unhide any sheet that is currently hidden or very hidden. If you want to unhide a specific sheet, you can modify the code by replacing the loop with:

Sub UnhideSpecificSheet()
    Dim ws As Worksheet
    ' Set the sheet you want to unhide
    Set ws = ThisWorkbook.Worksheets("SheetName") ' Replace "SheetName" with your sheet's name
    ' Unhide the specific worksheet
    ws.Visible = xlSheetVisible
End Sub

Be sure to replace `”SheetName”` with the actual name of the worksheet you wish to unhide. If you don’t know a sheet’s name, running the first script will reveal all sheets, allowing you to inspect their names directly.

Unlock Your Potential

Excel

Basic - Advanced

Access

Access Basic - Advanced

Power BI

Power BI Basic - Advanced

Help us grow the project