How to Delete Hidden Columns in Excel (2 Simple Methods)

Method 1 – Using the Inspect Document Feature in Excel to Delete Hidden Columns

STEPS:

  • Select column D.
  • Right-click and choose Hide.

Use Inspect Document Feature in Excel to Delete Hidden Columns

  • Column D will be hidden.

Use Inspect Document Feature in Excel to Delete Hidden Columns

  • Go to File.

  • Click Info, then Check for Issues.
  • Choose Inspect Document.

Use Inspect Document Feature in Excel to Delete Hidden Columns

  • Click on Yes in the new Microsoft Excel window.

  • In the Document Inspector window, choose Inspect.

Use Inspect Document Feature in Excel to Delete Hidden Columns

  • Select Hidden Rows and Columns as well as Remove All.
  • Click on Close.

Use Inspect Document Feature in Excel to Delete Hidden Columns

  • It will delete the hidden column.

Read More: How to Delete Every Other Column in Excel


Method 2 – Deleting Hidden Columns Through Excel VBA

2.1 Delete from Specific Range

STEPS:

  • Select column D.
  • Right-click and choose Hide.

Column D will be hidden.

Delete from Specific Range

  • Navigate to Developer, then Visual Basic.

  • Choose Insert and click Module.

Delete from Specific Range

  • Enter the following VBA code into the Module box.
Sub DeleteHiddenColumns()
Dim sheet As Worksheet
Dim rng As Range
Dim LastColumn As Integer
Dim ColumnCount As Integer
Set sheet = ActiveSheet
Set rng = Range("A:E")
ColumnCount = rng.Columns.Count
LastColumn = rng.Columns(rng.Columns.Count).Column
For i = LastColumn To LastColumn - ColumnCount Step -1
If Columns(i).Hidden = True Then Columns(i).EntireColumn.Delete
Next
End Sub
  • Press F5 or click Run.

  • It will delete the hidden column.

Delete from Specific Range

Read More: How to Delete Column in Excel Without Affecting Formula


2.2 Erase from Whole Worksheet

STEPS:

  • Choose columns C and E.
  • Right-click and select Hide.
  • Both the C and E columns will be hidden.

Erase from Whole Worksheet

  • Click Developer and then Visual Basic.

Erase from Whole Worksheet

  • Select Insert and then click Module.

  • Enter the code below into the Module box.
Sub DeleteHiddenColumns()
Dim sheet As Worksheet
Dim LastColumn
Set sheet = ActiveSheet
LastColumn = sheet.UsedRange.Columns(sheet.UsedRange.Columns.Count).Column
For i = LastColumn To 1 Step -1
If Columns(i).Hidden = True Then Columns(i).EntireColumn.Delete
Next
End Sub
  • Hit F5 or select the Run button.

Erase from Whole Worksheet

  • It will delete the hidden columns.

Erase from Whole Worksheet


Download Practice Workbook


Related Articles


<< Go Back to Delete Columns | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Lutfor Rahman Shimanto
Lutfor Rahman Shimanto

Lutfor Rahman Shimanto, BSc, Information Technology, Jahangirnagar University, Bangladesh, has worked with the ExcelDemy project for over a year. He has written 50+ articles and provided solutions of 100+ comments for ExcelDemy. Currently, he works as an Excel & VBA Developer and provides support and solutions in the ExcelDemy Forum. He has solved 100+ ExcelDemy Forum problems. His work and learning interests are in developing various Excel & VBA and Desktop applications. Outside of work, he enjoys Chess... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo