Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to sort rows to put the blank cells on top in Excel?

If you have a list of data which is populated with some blank cells, now, you need to sort all the empty cells on top of the data. When you apply the Sort feature in Excel, both the Sort Smallest to Largest and Sort Largest to Smallest functions will sort the blank cells at the bottom of the records. In this case, the following tutorial will talk about how to sort rows and put the blank cells on top in Excel.

Sort rows to put the blank cells on top by sorting colored cells

Sort rows to put the blank cells on top with a helper column

Sort rows to put the blank cells on top with VBA code

Easily sort rows to put the blank cells on top with Kutools for Excel (several clicks)


Combine multiple worksheets/workbooks into one worksheet / workbook:

Combine multiple worksheets or workbooks into one single worksheet or workbook may be a huge task in your daily work. But, if you have Kutools for Excel, its powerful utility – Combine can help you quickly combine multiple worksheets, workbooks into one worksheet or workbook.

Kutools for Excel includes more than 300 handy Excel tools. Free to try with no limitation in 30 days. Read More      Free Download Now

Excel Productivity Tools

Office Tab: Bring powerful tabs to Office (include Excel), just like Chrome, Safari, Firefox and Internet Explorer. Save you half the time, and reduce thousands of mouse clicks for you. 30-day Unlimited Free Trial

Kutools for Excel: Save 70% of your time and solve 80% Excel problems for you. 300+ advanced features designed for 1500+ work scenario, make Excel much easy and increase productivity immediately. 60-day Unlimited Free Trial


Sort rows to put the blank cells on top by sorting colored cells


In Excel, you can sort data by background color, so here, you can fill the blank cells with a specific color, and then sort them by color. Please do with the following steps:

1. Select your list of data, and press Ctrl + G to open the Go To dialog, then click Special button, see screenshot:

doc-sort-blanks-first1

2. In the popped Go To Special dialog box, check Blanks option, and then click OK.

doc-sort-blanks-first1

3. And all the empty cells have been selected, now you can fill them with a color by clicking Home > Fill Color and selecting a color you want as following screenshot shown:

doc-sort-blanks-first1

4. Then you can sort the list by filling color, please select your values and click Data > Sort, in the popped Sort dialog, select the column that you want to sort, and choose Cell Color from the Sort On drop down list, then click the color of the blank cells, finally, choose On Top option. See screenshot:

doc-sort-blanks-first1

5. After finishing the settings, click OK, all the colored blank cells have been sorted first, then you can remove the color after sorting. See screenshots:

doc-sort-blanks-first5 -2 doc-sort-blanks-first6

Sort rows to put the blank cells on top with a helper column

To sort the blank cells at the top of your data list, you can use a formula to identify the blanks, and then apply the Sort function.

1. In a blank cell which next to the data, cell B1, for instance, type this formula =A1="",see screenshot:

doc-sort-blanks-first1

2. Then drag the fill handle over to the cells that you want to contain this formula, and all the blank cells displayed as TRUE, and others as False, see screenshot:

doc-sort-blanks-first1

3. Then click Data > Sort Largest to Smallest, and a Sort Warning dialog will pop up, then check Expand the selection, see screenshots:

doc-sort-blanks-first9
-1
doc-sort-blanks-first10

4. And then click OK, all the blank cells have been sorted on the top of the values.

doc-sort-blanks-first1

5. At last, you can delete the values in helper column B as your need.


Sort rows to put the blank cells on top with VBA code

Apply the following VBA code, you can quickly sort the blank cells on top of the data.

1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module Window.

VBA code: Sort the blank cells on top of the data

Sub SortBlankOnTop()
'Update 20140318
On Error Resume Next
Dim WorkRng As Range
Dim xMin As Double
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
xMin = Application.WorksheetFunction.Small(WorkRng, 1) - 1
WorkRng.SpecialCells(xlCellTypeBlanks) = xMin
WorkRng.Sort , Key1:=Cells(WorkRng.Row, WorkRng.Column), Order1:=xlAscending, Header:=xlNo, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
WorkRng.Replace What:=xMin, Replacement:="", LookAt:=xlWhole
End Sub

3. Then press F5 key to run this code, in the popped dialog, select the data range that you want to sort, see screenshot:

doc-sort-blanks-first1

4. And then click OK, the empty cells have been sorted on top.


Easily sort rows to put the blank cells on top with Kutools for Excel

The Advanced Sort utility of Kutools for Excel can help you easily sort rows and put the blank cells on top in Excel. Please do as follows.

Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 60 days.

1. Select the range you want to sort and put the blank cells on top, and then click Enterprise > Advanced Sort. See screenshot:

2. In the Advanced Sort dialog box, select your sorting condition, and then check the Blank cells in front box, and finally click the OK button. See screenshot:

doc blank cell first

Then the selected range is sorted and all blank cells are put on top immediately. See screenshot:

Tip.If you want to have a free trial of this utility, please go to download the software freely first, and then go to apply the operation according above steps.


Easily sort rows to put the blank cells on top with Kutools for Excel

Kutools for Excel includes more than 300 handy Excel tools. Free to try with no limitation in 60 days. Download the free trial now!


Related articles:


Excel Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 70%, and Help You To Stand Out From Crowd

Would you like to complete your daily work quickly and perfectly? Kutools for Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for you.

  • Designed for 1500+ work scenarios, helps you solve 80% Excel problems.
  • Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  • Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands.
  • Become an Excel expert in 3 minutes. No longer need to remember any painful formulas and VBA codes.
  • 60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  • Being used by 110,000 elites and 300+ well-known companies.

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • One second to switch between dozens of open documents!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Shebu · 1 years ago
    A trick that was easy for me was to put a value of "0" in all blank cells and then conditionally format those cells with a "0" to have white font. Then I could easily sort by value and the "0" cells would appear on the top but visually they appear blank because the font matches the background. This may not work if you're using the cells for metrics purposes, this was merely for sorting.
  • To post as a guest, your comment is unpublished.
    Pravin · 2 years ago
    Great Post.............It help me lots of..........

    Thank you so much.