VBA : Excel VBA to Unhide All Worksheets at Once

  • A limitation with Excel is you can only unhide one worksheet at a time. Below is some code that allows the user to unhide as many worksheets as they choose, at once.


    Create a ListBox (Call it ListBox1) and a Command Button (Call it CommandButton1) in an Excel Worksheet.
    Make sure that the MultiSelect Feature is selected on the ListBox. To choose the multiselect feature, doubleclick on the list box in design mode, choose Categorized, and then under MultiSelect choose the 3rd option, fmMultiSelectExtended.


    Go to the VBA Code Editor on the worksheet that contains the listbox and command button, and add the following code:


    Private Sub CommandButton1_Click()


    Dim i As Integer
    i = 0


    Dim x As Integer
    x = ListBox1.ListCount - 1


    For i = 0 To x
    If ListBox1.Selected(i) = True Then
    Worksheets(i + 1).Visible = False
    End If
    Next i

    End Sub


    Now just choose which worksheets you want to hide and hit the button.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!