Is it possible to unhide all columns in an Excel sheet using VBA?

The VBA (Visual Basic for Applications) programming language allows for automation and customization of tasks in Microsoft Excel. One task that can be automated is unhiding all columns in an Excel sheet. This means that with a simple VBA code, it is possible to reveal all hidden columns in a sheet, saving time and effort for the user. By utilizing the power of VBA, this task can be completed efficiently and effectively, making it a valuable tool for managing large amounts of data in Excel.

Unhide All Columns Using VBA (With Example)


You can use the Hidden property in VBA to unhide a column in a given sheet.

To unhide all columns in a given sheet, you can use the following syntax:

Sub UnhideAllColumns()

Columns.EntireColumn.Hidden = FalseEnd Sub

By using the Hidden property and specifying a value of False, we tell Excel to unhide all columns in the current sheet.

The following example shows how to use this syntax in practice.

Example: How to Unhide All Columns Using VBA

Suppose we have an Excel sheet that contains information about various basketball players:

Now suppose we highlight columns A and B, then right click and then click Hide:

Both columns will become hidden:

Now suppose we would like to use VBA to automatically unhide all columns in this sheet.

We can create the following macro to do so:

Sub UnhideAllColumns()

Columns.EntireColumn.Hidden = FalseEnd Sub

Once we run this macro, all columns will become unhidden:

Note that if you’d like to unhide all columns in all sheets of an Excel workbook, you could create the following macro to do so:

Sub UnhideAllColumnsAllSheets()

Dim ws As Worksheet

    For Each ws In Worksheets
        ws.Columns.EntireColumn.Hidden = FalseNext ws

End Sub

By using a simple For Each loop, we can loop through each sheet in our workbook and unhide all columns in each sheet.

Note: You can find the complete documentation for the Hidden property in VBA .

Additional Resources

The following tutorials explain how to perform other common tasks in VBA:

x