Skip to the stories
Excel & Power BI

Remove Blank Columns in Excel with Go To Special, COUNTA or Power Query

  • Chris Menard
  • 974 views

Blank columns can split Excel data and break sorting. Choose Go To Special, a COUNTA helper row or Power Query based on how the columns are labeled.

Remove Blank Columns in Excel with Go To Special, COUNTA or Power Query

Blank columns can split an Excel dataset into separate blocks. That can cause a sort on Order ID to move only part of each row, leaving customer, product and total values beside the wrong order. The fix depends on whether the empty columns have headers and whether you receive the same untidy data repeatedly.

Delete Blank Columns in Excel: 3 Easy Ways

Three approaches cover those cases: Go To Special for columns with blank headers, a COUNTA helper row for columns that have headers but no data, and Power Query for a cleanup you can refresh when new data arrives. The examples below use columns C, F and J, but the same issue can affect blank rows.

Why empty columns disrupt Excel data

Excel can interpret a completely empty column as the edge of a data block. In the example, blank columns C, F and J divide what should be one order table into four sections. When the Order ID column is sorted from largest to smallest, Excel moves columns A and B but leaves the later blocks in place. The order details no longer match their IDs.

Columns C, F, and J are blank and divide an order dataset
Columns C, F and J split the order data into separate blocks.
Sorting Order IDs moves only the data before the first blank column
After sorting by Order ID, the other fields remain in place, so row values no longer match.

Filtering and PivotTables can also treat those separated blocks as distinct data. Removing the empty columns restores a continuous range that Excel can handle as one dataset.

Remove columns with blank headers using Go To Special

Go To Special is the quickest option when an empty column has no header and you know there is no data anywhere below it. In this example, cells C1, F1 and J1 are blank, and the columns beneath them are empty too.

Select the header row from A1 through L1, then press Ctrl + G to open the Go To dialog. Click Special, select Blanks and choose OK. Excel selects the blank cells in the selected header row.

Select the header row and open the Go To dialog
Select the headers before opening Go To with Ctrl + G.
Choose Blanks in the Go To Special dialog
Go To Special selects the empty cells in the header row.

With those cells selected, use Home > Delete > Delete Sheet Columns. Excel removes each selected column, including its cells below the header.

Delete the selected blank worksheet columns
Choose Delete Sheet Columns to remove the blank columns together.

Check the result with a sort. Right-click a cell in A2, choose Sort, and sort Z to A. The whole row should now move together; Granite Partners, for example, moves to the bottom with its order details. Press Ctrl + Z if you want to undo the sort and restore the earlier order.

A sort keeps each order's fields together after blank columns are removed
After deleting the gaps, sorting keeps each order's details aligned.

Find header-only columns with COUNTA

Go To Special on the header row won’t identify a column whose header contains text. In the second example, C1, F1 and J1 all say “Notes,” but the cells below each header are empty. Since those header cells aren’t blank, Excel doesn’t select them with the previous method.

Notes columns have headers but no values beneath them
Columns with a header and no entries need a check beyond the header row.

Add a helper row above the headers. In A1, enter a COUNTA formula covering the data rows in that column:

=COUNTA(A2:A22)

In this example, column A returns 21: one header plus 20 data entries. Copy the formula across the helper row. COUNTA counts cells that aren’t empty, so a column containing only its header returns 1. Columns with values below the header return a higher count.

COUNTA identifies columns containing only a header
A result of 1 marks a column with a header and no data beneath it.

Use the results to identify the header-only columns—in this case C, F and J—then delete those worksheet columns. Remove the helper row afterward. Set the formula range to cover all the data rows in your own file; the example range ends at row 22.

Make repeated cleanup easier with Power Query

When the same kind of messy data arrives regularly, Power Query lets you inspect and remove empty columns in a query, then refresh that query for later data. Start with the original data containing the blank columns. Click A1 and press Ctrl + Shift + End to select through the last used cell, including the blank columns between data.

Select the used range including blank columns with Ctrl Shift End
From A1, Ctrl + Shift + End selects the used range, including the gaps.

Choose Data > From Table/Range. In the Create Table dialog, confirm My table has headers is checked. The example names the table tbl_orders; if your Excel version offers a name field in this dialog, you can enter a table name there. Click OK to open Power Query Editor.

Create a table from the selected data and confirm the header setting
Confirm that the selected range has headers before opening Power Query.

Use Column quality to spot completely empty fields

Blank columns may appear in Power Query as Column1, Column2 and Column3. To review them without scanning across the preview, open the View tab and turn on Column quality in the Data Preview group.

Enable Column quality in Power Query Editor
Column quality displays Valid, Error and Empty percentages below each column name.

The quality indicators show the share of values that are valid, errors or empty. In the example, Order ID and Order Date are 0% empty, while Column1 is 100% empty. Hover over its indicator to see the count: all 20 of 20 rows are blank.

Column quality shows every row in Column1 is empty
Column1 is 100% empty; the hover detail confirms 20 blank rows out of 20.

Column2 and Column3 are also 100% empty. Region and Status are only 10% empty, so those columns contain data alongside some missing values. Keep them: a partially empty field isn’t the same as a completely blank column.

Column quality distinguishes fully empty fields from partly empty Region and Status columns
Remove the 100% empty columns; Region and Status contain values and should remain.

To remove the empty fields, hold Ctrl and select the Column1, Column2 and Column3 headers. Right-click and choose Remove Columns. When the query is ready, select Home > Close & Load. For the next batch of data, refresh the query to repeat the saved cleanup.

Choose the method that fits the data

Use Go To Special when the blank columns also have blank headers and contain no data. Use COUNTA when headers are present but the columns have no entries beneath them. For data that arrives in the same messy layout repeatedly, Power Query’s Column quality view makes fully empty columns easy to spot and lets you reuse the cleanup on refresh.

Before deleting anything, confirm that a column is truly empty. A column with some missing values may still carry useful information; the example’s Region and Status fields show why checking the empty percentage matters.

Source: Chris Menard · chrismenardtraining.com

Neighbouring cells