Excel VBA code to Delete Hidden Columns example will help us to delete Columns in excel worksheet which are hidden. We can use Delete method of Columns to delete the Hidden Columns. In this example we will see how to delete the Hidden Columns in excel worksheet using VBA. Excel VBA Macro code for deleting Hidden Columns macro should work for all the version of Microsoft Excel 2003, Excel 2007, Excel 2010, and Excel 2013.

VBA Delete Hidden Columns Excel Macro Example Code

VBA code to Delete Hidden Columns

Here is the Example VBA syntax and Example VBA Macro code to Delete Hidden Columns from excel worksheets. This will help you to know how to delete Hidden Columns from Excel workbook using VBA.

VBA Delete Hidden Columns: Syntax

Following is the VBA Syntax and sample VBA macro command to Delete Hidden Columns from worksheet using VBA. We are using the Delete method of the Columns object of worksheet.

If Columns(ColumnNumber).Hidden = True Then Columns(ColumnNumber).EntireColumn.Delete

Here Columns(ColumnNumber).Hidden is to check if the Column is hidden. And EntireColumn.Delete method will delete the Columns from the Excel spreadsheet if they are hidden.

Delete Hidden Columns using VBA: Examples

The following Excel VBA macro code is to delete Hidden Columns from the worksheet. This VBA macro will delete the Column which are hidden.

Sub sbVBS_To_Delete_Hidden_Columns()
Dim lastColumn
lastColumn = 100
    For iCntr = lastColumn To 1 Step -1
        If Columns(iCntr).Hidden = True Then Columns(iCntr).EntireColumn.Delete
End Sub 

Instructions to run the VBA Macro code to delete Hidden Columns

Please follow the below steps to execute the VBA code to delete Hidden Columns.
Step 1: Open any existing Excel workbook
Step 2: Press Alt+F11 – This will open the VBA Editor
Step 3: Insert a code module from then insert menu
Step 4: Copy the above code and paste in the code module which have inserted in the above step
Step 5: enter some sample data and hide some Columns for testing purpose
Step 6: Now press F5 to execute the code

Now you can observe that the Hidden Columns are deleted from worksheet.

Explained VBA Code to Delete Hidden Columns:

Starting program and sub procedure to write VBA code to delete Hidden Columns from sheet.

Sub sbVBS_To_Delete_Hidden_Columns()

‘Declaring the variable lastColumn to store the last Column in the worksheet
Dim lastColumn As Long

‘Declaring the iCntr to use it in for loop
Dim iCntr As Long

‘assigning the values to the last Column
lastColumn = 100

‘looping through the Columns using for loop from bottom to top
For iCntr = lastColumn To 1 Step -1
‘checking the Column is hidden.
‘Deleting the hidden Columns
If Columns(iCntr).Hidden = True Then Columns(iCntr).EntireColumn.Delete
End Sub
Ending the Excel VBA Macro to delete the hidden Columns.

Premium Project Management Templates

50+ Professional Project Management Templates!

A Powerful & Multi-purpose Templates for project management. Now seamlessly manage your projects, tasks, meetings, presentations, teams, customers, stakeholders and time. This page describes all the amazing new features and options that come with our premium templates.


50+ Project Management Templates Pack

Excel PowerPoint Word


Ultimate Project Management Template – Advanced

Excel Template



Excel Template


20+ Excel Project Management Pack

Excel Templates


20+ PowerPoint Project Management Pack

PowerPoint Templates


10+ MS Word Project Management Pack

Word Templates


By Published On: April 22nd, 2014Categories: VBATags:

Share This Story, Choose Your Platform!

About the Author: PNRao

PNRao is a passionate business analyst and having close to 10 years of experience in Data Mining, Data Analysis and Application Development. This blog is his passion to learn new skills and share his knowledge to make you expertise in Data Analysis (Excel, VBA, SQL, SAS, Statistical Methods, Market Research Methodologies and Data Analysis Techniques).

Leave A Comment