Deleting multiple columns; empty or unnecessary is quite a desirable task in Excel operations. If you are looking for some special tricks to know how to delete multiple columns in Excel, you’ve come to the right place. We’ll show 5 suitable methods to delete multiple columns in Excel. This article will discuss every step of the methods. Let’s follow the complete guide to learn all of this.
Download Practice Workbook
Download this practice workbook to exercise while you are reading this article. It contains all the datasets in different spreadsheets for a clear understanding. Try it yourself while you go through the whole process.
5 Suitable Methods to Delete Multiple Columns in Excel
In this article, we use Excel tools such as Delete, Cell Option, Function & VBA macro code to delete consecutive or non-consecutive empty or unnecessary columns. We generate a dataset of employees’ Ids, Names, Origins, etc; where some columns are kept emptied & some are unnecessary.
You should learn and apply these to improve your thinking capability and Excel knowledge. We use the Microsoft Office 365 version here, but you can utilize any other version according to your preference.
1. Delete Columns Through Context Menu
Here, we will demonstrate how to delete multiple columns through the context menu. Let’s say the Salary and Joining Month & Joining Date columns in my dataset are not needed. They must be removed. Let’s walk through the following steps to do the task.
- First, select the three columns (Joining Month, Joining Date & Salary).
- Then, right-click on any selected column. An options menu will pop up.
- You can press CTRL & click on the columns you want to select.
- Next, click Delete.
- Therefore, the outcome will be similar to the one shown in the picture below.
- Now, we will show how to delete random empty multiple columns.
- Next, select random multiple empty columns by pressing CTRL, then click on the columns.
- Then, right-click on the selected columns, and a window will pop up.
- Next, click Delete. The outcome is shown in the image below.
Read more: Delete Blank Columns in Excel
2. Use Delete Sheet Columns Option in Home Tab
In this second method, we will illustrate how to use the Delete Sheet Columns option in the Home tab in Excel. Let’s follow the following steps to do the task.
- First, select unnecessary columns or empty columns by pressing CTRL and Clicking on any desired column.
- Next, go to the Home tab >> Delete >> Delete Sheet Columns.
- Consequently, the final image will be similar to the one shown in the image below.
3. Utilize Find & Select Feature
Now, we will show how to delete multiple columns using the Find & Select feature. To complete the task, let’s go through the steps below.
- First, go to Home >> Find & Select >> click on Go to Special.
- Consequently, a dialog window will pop up.
- Select Blanks then click OK.
- Therefore, blank columns get selected.
- Next, right-click on any of the selected columns, and a pop-up options menu will appear. Click Delete.
- Hence, a command dialog box pops up.
- Then, select Entire Column. Click OK.
- How to Delete Unused Columns in Excel(Easiest 5 Methods)
- Delete Columns in Excel Without Affecting Formula (Two Ways)
- Delete Extra Columns in Excel (7 Methods)
4. Use of COUNTA Function
In this fourth method, we will show how to use the COUNTA function to delete multiple cells in Excel. Let’s go through the steps listed below to finish the task.
- In the case of deleting 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.
- First, insert a helper row at the top of the dataset.
- And clear the column names of Empty columns.
- Next, write down the following formula in cell B3.
- Then press Enter and drag the Fill Handle icon towards the right.
- Therefore, True and False text will appear above each column.
- Afterward, select the data range including the helper row.
- Next, click on Data Ribbon >> select Sort.
- Consequently, a window pops up.
- Click on Options (a command dialog box pop up) >> select Sort left to Right >> click OK.
- Next, in that Sort window, select ROW 3 (from the Sort by drop-down menu).
- Then keep Cell Values (from Sort On drop-down menu ) >> select Largest to Shortest (from Order drop-down menu).
- Next, click OK. The result will be similar to the image below.
- Then, select all the blank columns >> Right click >> select Delete >> select Delete Entire Column.
- Finally, click OK.
- As a result, the outcome depicts the below image.
5. Apply Excel VBA
Finally, we will demonstrate how to delete multiple columns using Excel VBA. Let’s complete the task by adhering to the below-listed instructions.
- VBA has its own separate window to work with. You have to 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.
- Then, click on Module from the drop-down.
- As a result, a new module will be created.
- Now 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.
- Therefore, the result will be similar to the below image.
- Now, we will show another VBA code to delete multiple empty columns without a header.
- Repeat the above steps.
- Then, copy the below Code & Paste >> 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
- Next, save the code.
- Afterward, close the Visual Basic window. After that press Alt+F8.
- When the Macro dialogue box opens, select the following macro in the Macro name. Click on Run.
- A pop-up dialog box will appear, go to the worksheet & select the range you desire. Click OK.
- Finally, the execution brings the result.
Deleting multiple columns; unnecessary, blank with or without headers quite useful to organize a dataset. In this article, we showed the simplest tools offered in Excel to delete multiple columns and also VBA code to delete multiple columns on a criteria basis. I hope, you find these methods super easy & handy. Comment, if further clarifications are needed or if you want to add something. Don’t forget to check our website Exceldemy.com for various Excel-related problems and solutions. Keep learning new methods and keep growing!
- How to Clear Contents in Excel Without Deleting Formulas (3 Ways)
- VBA to Delete Column in Excel (9 Criteria)
- VBA Macro to Delete Columns Based on Criteria in Excel (8 Examples)