Method 1 – Deleting Multiple Columns Through Context Menu in Excel
Steps:
- Select the three columns (Joining Month, Joining Date & Salary).
- Right-click on any selected column. An options menu will pop up.
- Press CTRL & click on the columns you want to select.
- Click Delete.
- The outcome will be similar to the one shown in the picture below.
- Show how to delete random empty multiple columns.
- Select random multiple empty columns by pressing CTRL, then click on the columns.
- Right-click on the selected columns and a window will pop up.
- Click Delete. The outcome is shown in the image below.
Method 2 – Using Delete Sheet Columns Option in Home Tab for Removing Multiple Columns
Steps:
- Select unnecessary columns or empty columns by pressing CTRL and clicking on any desired column.
- Go to the Home tab >> Delete >> Delete Sheet Columns.
- The final image will be similar to the one shown in the image below.
Method 3 – Deleting Specific Columns After Selecting Through Find & Select Feature
Steps:
- Go to Home >> Find & Select >> click on Go to Special.
- A dialog window will pop up.
- Select Blanks, click OK.
- All blank columns are selected.
- Right-click on any selected columns and a pop-up options menu will appear. Click Delete.
- A command dialog box pops up.
- Select Entire Column and click OK.
Method 4 – Eliminating Specific Columns After Finding Through COUNTA Function
Steps:
- If we want to delete multiple blank columns, we can use the function COUNTA >> to show a specific text (True or False) >> Sorting (according to the text; True or False) >> Delete.
- Insert a helper row at the top of the dataset.
- Clear the column names of empty columns.
- Write down the following formula in cell B3.
=COUNTA(B4:B1048576)=0
- Press Enter and drag the Fill Handle icon towards the right.
- True and False text will appear above each column.
- Select the data range, including the helper row.
- Click on Data Ribbon >> select Sort.
- A window pops up.
- Click on Options (a dialog box pops up) >> Select Sort left to Right >> click OK.
- In that Sort window, select Row 3 (from the Sort by drop-down menu).
- Choose Cell Values (from Sort On drop-down menu ) >> Select Largest to Shortest (from Order drop-down menu).
- Click OK. The result will be similar to the image below.
- Select all the blank columns >> Right click >> Select Delete >> Select Delete Entire Column.
- Click OK.
- The outcome depicts the below image.
Method 5 – Applying Excel VBA to Delete Multiple Columns
Steps:
- VBA has its own separate window. You must insert the code in this window, too.
- To open the VBA window, click the Developer tab on your ribbon.
- Then select Visual Basic from the Code group.
- VBA modules hold the code in the Visual Basic Editor. It has a.bcf file extension. We can create or edit one easily through the VBA editor window.
- To insert a module for the code, go to the Insert tab on the VBA editor.
- Click on Module from the drop-down.
- As a result, a new module will be created.
- Select the module if it isn’t already selected. Then write down the following code in it.
Sub delete2()
Dim xEnd1Col As Long
Dim I As Long
Dim XDel1 As Boolean
On Error Resume Next
xEnd1Col = Cells.Find("*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
If xEnd1Col = 0 Then
MsgBox "No data available""" & ActiveSheet.Name & """ .", vbExclamation, "delete Multiple columns"
Exit Sub
End If
Application.ScreenUpdating = False
For I = xEnd1Col To 1 Step -1
If Application.WorksheetFunction.CountA(Columns(I)) <= 1 Then
Columns(I).Delete
XDel1 = True
End If
Next
If XDel1 Then
MsgBox "You have deleted all columns"
Else
MsgBox "No remaining column"
End If
Application.ScreenUpdating = True
End Sub
- Press F5 to execute the code.
- A pop-up dialog box will appear. Click OK.
- The result will be similar to the below image.
- We will show another VBA code to delete multiple empty columns without a header.
- Repeat the above steps.
- Copy the below code in the code window.
Public Sub Deleteing1()
Dim Source1Range As Range
Dim Entire1Column As Range
On Error Resume Next
Set Source1Range = Application.InputBox("You have to selecet range of data:", "Delete Multiple columns", Application.Selection.Address, Type:=8)
If Not (Source1Range Is Nothing) Then
Application.ScreenUpdating = False
For I = Source1Range.Columns.Count To 1 Step -1
Set Entire1Column = Source1Range.Cells(1, I).Entire1Column
If Application.WorksheetFunction.CountA(Entire1Column) = 0 Then
Entire1Column.Delete
End If
Next
Application.ScreenUpdating = True
End If
End Sub
- Save the code.
- Close the Visual Basic window. After that, press Alt + F8.
- When the Macro dialogue box opens, select the desired macro and click on Run.
- A pop-up dialog box will appear, go to the worksheet and select the range you desire. Click OK.
- The execution brings the result.
Download Practice Workbook
Related Articles
- How to Delete Every Other Column in Excel
- How to Delete Column in Excel Without Affecting Formula
- How to Delete Unused Columns in Excel
- How to Delete Column in Excel Without Affecting Formula
- How to Delete Unused Columns in Excel
- How to Delete Infinite Columns in Excel
- How to Delete Hidden 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!