Sunday, February 16, 2025
No menu items!
HomeData Analytics and VisualizationVBA: How to Unhide One or Multiple Columns

VBA: How to Unhide One or Multiple Columns

This tutorial explains how to unhide one or multiple columns in Excel using VBA.

You can download the following dataset to practice.



Syntax to Unhide a Column

This code Columns("A").Hidden = False unhides the column A.

1. Unhide a Column

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.

VBA :  Unhide a Column
2. Unhide Multiple Columns

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.

VBA : Unhide Multiple Columns
3. Unhide Specific Columns

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.

VBA : Unhide Specific Columns

Read MoreListenData

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments