Search

Friday 27 September 2019

Excel hidden sheets, unhide all macro button

This short guide contains the instructions on how to create a menu ribbon button that unhides all hidden sheets.
The button actually triggers a macro, details of which are below.
  1. Open a new excel workbook
  2. Start to record a new macro

    1. Give the macro a name “unhide_all_sheets”, and store the macro in “Personal Macro Workbook”
    2. Type a short string into any cell, then stop the macro recording


  3. Now, lets edit the macro.
    Via the keyboard, press “ALT + F11”.
  4. In the “Microsoft Visual Basic for Applications” window,
    in the “Project” pane, find and open the newly created module in the “PERSONAL.XLSB” VBAProject.

  5. Replace the code with the code below
  6. Sub unhide_all_sheets()
    For Each sh In Worksheets: sh.Visible = True: Next sh
    End Sub

  7. Close the window, and confirm that the macro is available by clicking on the menu options
    View > Macros


  8. To add this macro as a button in the excel ribbon, click on the “Customize Quick Access Toolbar” button at the top of excel, and then click on the “More Commands” option
  9. Add the macro to the toolbar
    1. In the “Choose commands from” change the dropdown to show “Macros”
    2. Click on the “PERSONAL.XLSB!unhide_all_sheets” macro
    3. Click on “Add” to add this macro onto the right-side window
    4. Optionally click on the “Modify” button to change the icon for the macro, and then click OK to save changes
  10. Test the button by creating and hiding new excel sheets in the same workbook to show that the hidden sheets are unhidden.

No comments:

Post a Comment