This tutorial explains how to unhide one or multiple columns in Excel using VBA.
You can download the following dataset to practice.
This code Columns("A").Hidden = False
unhides the column A.
In this example we will try to unhide column B of a given data set.
Sub UnhideSingleColumn() Dim ws As Worksheet Set ws = ThisWorkbook.ActiveSheet ws.Columns("B").Hidden = False End Sub
Press Run or F5 to run the above code.
We want to unhide all the columns that are arranged continuously (one after another) from columns B through D.
Sub UnhideMultipleColumns() Dim ws As Worksheet Set ws = ThisWorkbook.ActiveSheet ws.Columns("B:D").Hidden = False End Sub
Press Run or F5 to run the above code.
Let’s unhide columns B, D and F in a given data set. To do this we will use an array that stores the specific columns and then with the help of For Each loop
we can apply ThisWorkbook.ActiveSheet.Columns(colNam).Hidden = False
on each specific columns.
Sub UnhideSpecificColumns() Dim ws As Worksheet Dim colNam As Variant Set ws = ThisWorkbook.ActiveSheet For Each colNam In Array("B", "D", "F") ws.Columns(colNam).Hidden = False Next colNam End Sub
Press Run or F5 to run the above code.
Read MoreListenData