

Set rng = InputRng.Cells(1, i).EntireColumn Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, Type:=8)įor i = To 1 Step -1 VBA code: Delete multiple blank columns in selection: Click Insert > Module, and paste the following macro in the Module Window. Hold down the Alt + F11 keys in Excel, and it opens the Microsoft Visual Basic for Applications window.Ģ.
#How to delete blank columns in excel 2010 code#
The following VBA code may help you, please do as this:ġ.

If you'd like to use VBA macro, things goes much easier. Then, all empty columns have been sorted at the left of your data, and now, you just need to select all columns and then right click, choose Delete to delete these blank columns at once, see screenshot: Click OK button to return the Sort dialog, then select Row 1 from the Sort by drop down, and select Cell Values from Sort On section, choose Largest to Smallest from the Order section, see screenshot:Ħ. In the popped out Sort dialog box, click Options button, in the following Sort Options dialog, select Sort left to right option, see screenshots:ĥ. Then select the data range including the helper row, and then click Data > Sort, see screenshot:Ĥ. Then enter the below formula into cell A1, and then drag the fill handle to right side to apply this formula to other cells, a TRUE will be displayed if the column is blank, otherwise, a FALSE is displayed, see screenshot:ģ. Add a new row at the top of your data range, see screenshot:Ģ. In Excel, you can apply a formula to indentify if the columns are blank or not, and then use the Sort feature to sort all blank columns together, and then delete them at once. This article collects some tricky tips to help you delete multiple empty columns quickly.ĭelete multiple empty columns in worksheet with formulaĭelete multiple empty columns in worksheet with VBA codeĭelete multiple empty columns in selection / active sheet / whole workbook with a useful featureĭelete multiple empty columns with a header by using VBA code Therefore, some of us search for easy ways to solve this problem. It must be time-consuming to delete each empty column one by one. Sometimes when you import data to Microsoft Excel from some source, such as web page, CSV, text, etc., there may be many empty columns with it.
#How to delete blank columns in excel 2010 how to#
How to delete multiple empty columns quickly in Excel?
