Delete columns where all cells are empty

RogerC

Well-known Member
Joined
Mar 25, 2002
Messages
536
My spreadsheet has 350 columns, many of which contain only a header. Other columns may contain both values and blank cells.

Is there a non-VBA method to find and delete all columns where there are only blank cells below the header?

The 'Go To... Blanks' method to find blank cells won't work, because I don't want blank cells deleted from columns where some cells have data.
 
Thanks johnnyL.'s code (CountA(Columns(col)) = 1) doesn't catch completely empty columns. Try CountA(Columns(col)) <= 1 instead.

Your code seems to work with the exception of 5 columns. After running the macro the total number of columns went from 350 to 133. However, 5 columns within those 133 contain only Blank cells.

Of course, deleting them manually is manageable now, but do you have any idea why they would not have been deleted?
Johnny
 
Upvote 0

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,215,516
Messages
6,125,285
Members
449,218
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top