Thank you for Visiting my Blog

Thursday, 24 August 2017

VBA code to Hide & Unhide multiple Worsheets


Hiding worksheet manually is a tedious task when its more than one right ........No Worries here we have VBA code which HIDE and UNHIDE the multiple worksheets

HIDE :


Use the below highlighted code to hide the multiple worksheets:







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


Output:



 UNHIDE:

If you have multiple worksheet hided and you want to open them than below is the VBA code to unhide the multiple worksheets .....


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


 You may like to visit below :

How ForEach works in VBA
For.. Next Loop in VBA with example



 

No comments:

Post a Comment