Consider a situation in which you need to hide & unhide multiple sheets at a time. If someone is hiding & unhiding manually then this will take a lot of time.
In this article, you will learn how to dynamically hide or unhide multiple tabs using VBA code.
Q): I want a macro that will hide or unhide multiple tabs at one point of time.
Following is a snapshot of sheet1 in which there will be two dynamic lists i.e. Hide Tabs & Unhide Tabs
We need to follow the below steps:
This will create new module.
Enter the following code in the Module
LastTab = Range("Hide_TabsDNR").Count
On Error Resume Next
For TabNo = 2 To LastTab
Sheets(Range("Hide_TabsDNR")(TabNo)).Visible = False
Next TabNo
On Error GoTo 0
Sheets(1).Select
End Sub
Sub UnHideTabs()
Dim TabNo As Double
Dim LastTab As Double
LastTab = Range("Hide_TabsDNR").Count
On Error Resume Next
For TabNo = 2 To LastTab
Sheets(Range("UnHide_TabsDNR")(TabNo)).Visible = True
Next TabNo
On Error GoTo 0
Sheets(1).Select
End Sub
In this way we can dynamically hide or unhide multiple tabs at one time.
The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.
It's not working it showing error as Debug and something else.