56 free macros indexedAll toolsHow to runBlogGitHub ↗

Delete Empty Columns

Remove every column in your selection where all cells are empty or whitespace-only

windows · mac · Excel 2016+ · Free


What it does

CSV exports and Power Query refreshes often produce columns that are entirely blank. Maybe the source system had a "Notes 2" field nobody fills in. Maybe Power Query added a join column that ends up empty after a filter step. Excel has no built-in "delete columns where every cell is blank" option, so the workaround is to scroll, eyeball, Ctrl-click each empty column header, right-click, Delete. The macro does it in one pass. Select your range, run it, every column inside the selection where every cell is blank or whitespace-only gets removed. Deletion happens right-to-left so the column indices stay correct as the macro works.

Real-world example

Picture a marketing analyst at a mid-size e-commerce company, the Tuesday morning after a campaign launch. She's pulling the campaign performance export from the ad platform. The export comes through with 47 columns: campaign name, ad set, daily spend, impressions, clicks, the metrics she actually cares about. But also 22 columns the ad platform exports because someone enabled them once and never disabled them: things like "Audience Overlap Score", "TV Reach Index", "Branded Search Lift", which are empty for her account because she doesn't run TV ads or use the brand-lift module.

Her current workflow: open the CSV, scroll to the right looking for blank columns, Ctrl+click 22 column headers (which is fiddly because the columns aren't always contiguous), right-click, Delete. About 4 minutes per pull, longer if she clicks the wrong header and has to start the multi-select over.

With this macro she selects rows 1 through the last data row across all 47 columns, runs the tool, and 22 empty columns vanish in 1 second. The popup says "Removed 22 empty column(s)." She runs her usual pivot. Total elapsed: about 10 seconds.

On a typical 47-column campaign export with 22 empty columns, expect about 3 minutes saved per pull. Across daily pulls for a year that's roughly 18 hours back. The bigger win is no more "wait, did I delete a column I needed" moments because the macro only removes columns that were already empty.

How to use

First time? See How to run our tools for the 30-second setup.

  1. Select the range to scan. The macro deletes any column where every cell within your selected row range is empty.
  2. Press Alt + F8 (Windows) or Option + F8 (Mac), pick DeleteEmptyColumns, click Run.
  3. The macro deletes empty columns right-to-left and reports the count.

FAQ

Will it look at cells outside my selection?

No. The macro only checks cells inside your selected row range. So if your selection is rows 1 through 500 but a column has data in row 501, the macro still considers the column empty (because rows 1 to 500 are blank) and deletes the entire column, including the data in row 501. Always select the full height of your data, not just a sample.

What about columns with a header but no data?

These count as not-empty if the header cell has any text. So a column with "Notes 2" in row 1 and blanks below stays put. If you specifically want to remove header-only columns, exclude row 1 from your selection (start the selection at row 2) before running the macro.

What counts as empty?

A cell is empty if it's truly empty, contains an empty string "", or contains only whitespace characters. So a column where every cell has a stray space is still treated as empty and deleted. If you specifically need to keep whitespace-only columns, run Trim Whitespace From All Cells first to make the whitespace explicit, then decide what to do.

Will it delete columns that contain only formulas evaluating to empty?

A formula returning "" is treated as empty by the macro, so yes, that column gets deleted. If your "empty" cells are computed (like a conditional that returns blank for now but might return values later), copy the column as values first or run the macro on a different selection that excludes it.

Can I undo it?

Yes, Ctrl/Cmd + Z right after running undoes all column deletions in one step. As always with deletion macros, work on a copy of the file if it's the only copy. The macro runs entirely offline. Free, hosted on GitHub, source visible.

Did this tool work for you?

One click. We use this to fix tools that don't work and prioritize what to build next.

Related tools