Macro to Hide and UnHide worksheets in Excel


Hide all sheets in a workbook (except Active sheet)


Sub HideSheets()
Dim XLnCAD As Worksheet
For Each XLnCAD In ThisWorkbook.Worksheets
If XLnCAD.Name <> ThisWorkbook.ActiveSheet.Name Then
XLnCAD.Visible = xlSheetHidden
End If
Next XLnCAD
End Sub

Unhide every Hidden sheet in a workbook


Sub UnHideSheets()
Dim XLnCAD As Worksheet
For Each XLnCAD In ActiveWorkbook.Worksheets
XLnCAD.Visible = xlSheetVisible
Next XLnCAD
End Sub

How to use codes shared here?