How to Delete Multiple Empty Columns Quickly in Excel


Microsoft Excel is a strong data management and analysis programme with a plethora of capabilities. It's fairly uncommon to stumble across empty columns while working with huge spreadsheets, which clutter your data and make it tough to explore and work properly. Delete each empty column manually can be time−consuming and tiresome, especially when dealing with several columns.

Fortunately, Excel includes a variety of strategies for quickly deleting many empty columns, saving you considerable time and effort. We will walk you through the process of discovering and eliminating many empty columns in Excel in this article.

Deleting Multiple Empty Columns Quickly in Excel

Here we will first create a VBA module, then run it to complete the task. So let us see a simple example to demonstrate how you can delete multiple empty columns quickly in Excel.

Step 1

Consider an Excel sheet where you have data in table format with some blank columns, as shown in the following screenshot.

First, use Alt + F11 to open the VBA application.

Step 2

Then click on Insert, select Module, and copy the below code into the text box.

Insert > Module > Copy.

Example

Sub DeleteEmptyColumns()
Dim rng As Range
Dim InputRng As Range
xTitleId = "Delete Empty Columns"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, Type:=8)
Application.ScreenUpdating = False
For i = InputRng.Columns.Count To 1 Step -1
    Set rng = InputRng.Cells(1, i).EntireColumn
    If Application.WorksheetFunction.CountA(rng) = 0 Then
        rng.Delete
    End If
Next
Application.ScreenUpdating = True
End Sub

Step 3

Then, click F5 to run the module, select the range of data, and click OK to delete the multiple empty columns.

F5 > Select cells > Ok.

Conclusion

In this tutorial, we have used a simple example to demonstrate how you can delete multiple empty columns quickly in Excel to highlight a particular set of data.

Updated on: 20-Jul-2023

220 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements