Editor choice

How to Delete Multiple Columns in Excel: 5 Suitable Methods

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.

using context menu to Delete Multiple Columns in Excel

  • Show how to delete random empty multiple columns.
  • Select random multiple empty columns by pressing CTRL, then click on the columns.

select the desired columns to Delete Multiple Columns in Excel

  • Right-click on the selected columns and a window will pop up.
  • Click Delete. The outcome is shown in the image below.

 Delete Multiple Columns in Excel

 


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.

use delete sheet columns option to Delete Multiple Columns in Excel

  • 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.

use Find & Select feature to Delete Multiple Columns in Excel

  • A dialog window will pop up.
  • Select Blanks, click OK.

select Blank option

  • All blank columns are selected.

get the blank columns

  • 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.

use COUNTA function to Delete Multiple Columns in Excel

  • Select the data range, including the helper row.
  • Click on Data Ribbon >> select Sort.

select SORT option to Delete Multiple Columns in Excel

  • 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).

select order option to Delete Multiple Columns in Excel

  • 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.

 Delete Multiple Columns in Excel

 


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.

insert VBA window to Delete Multiple Columns in Excel

  • 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.

insert module to Delete Multiple Columns in Excel

  • 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.

click on 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.

select macro to Delete Multiple Columns in Excel

  • A pop-up dialog box will appear, go to the worksheet and select the range you desire. Click OK.

  • The execution brings the result.

 Delete Multiple Columns in Excel


Download Practice Workbook


Related Articles


<< Go Back to Delete Columns | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Maruf Islam
Maruf Islam

MARUF ISLAM is an excellent marine engineer who loves working with Excel and diving into VBA programming. For him, programming is like a superhero tool that saves time when dealing with data, files, and the internet. His skills go beyond the basics, including ABACUS, AutoCAD, Rhinoceros, Maxsurf, and Hydromax. He got his B.Sc in Naval Architecture & Marine Engineering from BUET, and now he's switched gears, working as a content developer. In this role, he creates techy content... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo