Hide or Unhide All Worksheets Using Macros in Excel

If you are facing trouble while trying to hide all messy worksheets in your Excel. Then this tutorial will help you to hide all worksheets by using the Macros in your Excel.

Before following the procedure of this tutorial make sure you have enabled the Excel’s Developer Tab.

Purpose of this tutorial: Hide all other worksheets except the active worksheet

Previously on Macros: How to Use Macros in Excel to Highlight the Duplicates?

Here is an example of messy workbooks/sheets;

Hide All Worksheets

STEP 1: GO TO DEVELOPER> CODE> VISUAL BASIC> COPY/PASTE THE CODE BELOW > CLOSE THE WINDOW

Copy the Code below;

Sub HideAllOtherWorksheets()
Dim worksheet As Worksheet
‘Loop through the worksheets
For Each worksheet In ThisWorkbook.Worksheets
‘Hide the sheet if it’s not the active sheet
If worksheet.Name <> ThisWorkbook.ActiveSheet.Name Then
worksheet.Visible = xlSheetHidden
End If
Next worksheet
End Sub

Hide All Worksheets1

STEP 2: Now first you have to open the sheet that contains data with the help of this procedure: Go to Developer > Code > Macros > Run

Hide All Worksheets2

Here is your result;

Hide All Worksheets Result

Learn NEXT – How To Unhide All Worksheet Using Macros In Excel