Monday, 22 September 2014

How to Hide or Unhide the Specific Sheets with Excel VBA Macro

Excel VBA Macro to Hide or Unhide the Specific Sheets
Let us suppose we have some sheets like...MyReports,My_Links,SLA_Report,Calls_Info in our Workbook.
If you want to Hide or UnHide when Click a Button , you have to assign the Macro to a Button.

Sub Hide_UnHide_TABS()

On Error Resume Next
Application.ScreenUpdating = False

'UnHide if Hideen

    If Sheets("MyReports").Visible = False Or Sheets("My_Links").Visible = False Or _
            Sheets("SLA_Report").Visible = False Or Sheets("Calls_Info").Visible = False Then
            Sheets("MyReports").Visible = True: Sheets("My_Links").Visible = True
            Sheets("SLA_Report").Visible = True: Sheets("Calls_Info").Visible = True
 'Hide if  UnHide
    ElseIf Sheets("MyReports").Visible = True Or Sheets("My_Links").Visible = True Or _
            Sheets("SLA_Report").Visible = True Or Sheets("Calls_Info").Visible = True Then
            Sheets(Array("MyReports", "My_Links", "SLA_Report", "Calls_Info")).Select
    ActiveWindow.SelectedSheets.Visible = False
    End If

Application.ScreenUpdating = True

End Sub


No comments:

Post a Comment

Hi User, Thank You for Visiting My Blog. Please Post Your Feedback/Comments/Query.

Subscribe to Blog Posts by Email

ExcelKingdom-Popular Posts

ExcelKingdom-Random Posts