Unhide All Rows and Columns

This simple macro automatically unhides all rows and columns for you.

VBA Code

Sub UnhideAll()
    Columns.EntireColumn.Hidden = False
    Rows.EntireRow.Hidden = False
End Sub

How This Macro Works

In this macro, we call on the Columns collection and the Rows collection of the worksheet. Each collection has properties that dictate where their objects are hidden or visible. Running this macro unhides every column in the Columns collection and every row in the Rows collection.

How to Use This Macro

To use this macro, you can copy and paste it into a standard module:

  1. Activate the Visual Basic Editor by pressing ALT F11.
  2. Right-click the project/workbook name in the Project window.
  3. Choose Insert -> Module.
    Insert Module
  4. Type or paste the code in the newly created module.

Comments

  1. Simon Wilson says

    Hi,
    When I put this in my code, it stops the macro after hiding the cells.
    I have other commands after inserting this line, boutton it will only execute until unhiding the rows, and no more.
    Can you help
    Thanks
    Simon

  2. davo says

    Simon – did you paste the “End Sub” line – this ends the routine. If you have other lines after it, “End Sub” ignores them. Delete that line from that position and make sure you have it at the end of your macro.

  3. Michael Wojciehowski says

    This is good for just having a quick macro.

    However, I am curious how I can build this into a long detailed code. I want to avoid the End Sub.

    I need to figure out how to unhide all rows after I have filtered and deleted data out. Does this question make sense?

  4. Dylan Sabo says

    To Unhide through all worksheets in a Workbook run the code below: …

    Sub UnhideAll()
    Dim ws As Worksheet
    Dim starting_ws As Worksheet
    Set starting_ws = ActiveSheet
    For Each ws In ThisWorkbook.Worksheets
    ws.Activate
    Columns.EntireColumn.Hidden = False
    Rows.EntireRow.Hidden = False
    Next
    starting_ws.Activate
    End Sub

  5. Vaughan says

    Hi. When I use this macro there is an error message that it s “unable to set the Hidden property of the range class”

  6. Vaughan says

    Sorry, this happens when the worksheet is protected, but the macros work when the sheet is unprotected.

  7. Ali says

    Hi. Am trying to create a VBA which pulls all worksheet into a master file but am unable to unhide the data which is hidden in the sheets. Can any one help me with this.
    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *