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 = False
End 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 = False
End Sub
Once we run this macro, all columns will become unhidden:
Notice that all columns from our original dataset are visible once again.
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 = False
Next 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 here.
Additional Resources
The following tutorials explain how to perform other common tasks in VBA:
VBA: How to Unhide All Sheets
VBA: How to Find Last Used Column
VBA: How to Count Number of Used Columns