Microsoft Excel is undoubtedly one of the most essential and potent computer programs currently available. Using Excel’s capabilities and resources, we can do unlimited computations on any dataset. This post will discuss two fundamental Excel methods for eliminating hidden columns. Therefore, use these 2 methods to delete hidden columns in Excel.
As an illustration, the below data set has some columns of Product, Month, Total Sales, and Sales Rep. Here, assume the D column alias Total Sales column is hidden. First, we are going to hide this column. Then, we’ll delete the Total Sale column in Excel using these two methods. Also, I have yet to mention that I’ve been writing this article using Microsoft Excel 365. However, you can use any other edition that provides maximum convenience.
1. Using the Inspect Document Feature in Excel to Delete Hidden Columns
The Inspect Document feature usually removes all the hidden rows and columns in an Excel worksheet. It’s important to know that we can’t bring back the columns we just deleted. So, if you want to keep the data for a while, you need to keep the backup. To complete the task to your delight, be sure to stick to the procedures that are given in the upcoming sections.
STEPS:
- First, select the D column.
- Right-click and choose Hide.
- The D column is now hidden.
- Go to File.
- Click Info, then Check for Issues.
- Choose Inspect Document.
- A new Microsoft Excel window appears and click on Yes.
- At this time, the Document Inspector window pops up.
- Next, choose Inspect.
- Select Hidden Rows and Columns as well as Remove All.
- Next, choose Close.
- It will provide the desired outcome, as seen below.
Read More: How to Delete Every Other Column in Excel
2. Deleting Hidden Columns Through Excel VBA
VBA is a sophisticated approach for removing hidden columns. We can accommodate two unique situations. One is eliminating columns using VBA from an individual worksheet. A second scenario is removing columns from a specific dataset range.
2.1 Delete from Specific Range
There are occasions when we are required to modify the font style of a specific range of data. The following section is going to be of great assistance to you in this particular circumstance. To complete the assignment quickly, kindly follow the instructions below.
STEPS:
- First, select the D column.
- Like previously, right-click and choose Hide.
- As a result, the D column has been hidden.
- Navigate to Developer, then Visual Basic.
- Choose Insert and click Module.
- Then, put 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 provide the desired result, as shown below.
Read More: How to Delete Column in Excel Without Affecting Formula
2.2 Erase from Whole Worksheet
In the next section, we’ll be able to delete hidden columns of the entire worksheet. Unlike previously, this time, we will hide two columns that are not contiguous. Follow the following guidelines to delete the hidden columns from a whole worksheet in Excel.
STEPS:
- Choose the C and E columns.
- Right-click and select Hide.
- Both the C and E columns have disappeared.
- Click Developer and then Visual Basic.
- Select Insert and then click Module.
- Now, insert 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.
- The intended outcome will finally be achieved, as seen below.
Download Practice Workbook
Conclusion
You can delete hidden columns in Excel using the procedures outlined above. There are more articles like this one on our website. Continue using them, and let us know if you have any alternative methods of completing the task or fresh ideas. Remember to submit questions, comments, or recommendations in the space below.
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 Empty Columns with Header in Excel
- How to Delete Columns with Specific Text in Excel
- [Solved!] Can’t Delete Extra Columns in Excel
<< Go Back to Delete Columns | Columns in Excel | Learn Excel
Get FREE Advanced Excel Exercises with Solutions!