Method 1 – Using the Inspect Document Feature in Excel to Delete Hidden Columns
STEPS:
- Select column D.
- Right-click and choose Hide.
- Column D will be hidden.
- Go to File.
- Click Info, then Check for Issues.
- Choose Inspect Document.
- Click on Yes in the new Microsoft Excel window.
- In the Document Inspector window, choose Inspect.
- Select Hidden Rows and Columns as well as Remove All.
- Click on Close.
- 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.
- Navigate to Developer, then Visual Basic.
- Choose Insert and click Module.
- 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.
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.
- Click Developer and then Visual Basic.
- 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.
- It will delete the hidden columns.
Download Practice Workbook
Related Articles
- How to Delete Multiple Columns in Excel
- How to Delete Blank Columns in Excel
- How to Delete Multiple Columns in Excel
- How to Delete Column in Excel Without Affecting Formula
- How to Delete Unused Columns in Excel
- How to Delete Multiple Columns in Excel with Condition
- How to Delete Unused Columns in Excel
- How to Delete Infinite Columns in Excel
- How to Delete Columns with Specific Text in Excel
- [Solved!] Can’t Delete Extra Columns in Excel
<< Go Back to Delete Columns | Learn Excel
Get FREE Advanced Excel Exercises with Solutions!