Sorting by name blank cell issue

pujo

Well-known Member
Joined
Feb 19, 2009
Messages
708
Office Version
  1. 2019
  2. 2013
Platform
  1. Windows
Hello,
I am trying to sort a column after an item is removed.
Is is sorted by name. I remove the name and hit sort and it works fine but I am left with a blank cell. Is there anything I can do for this?
Here is the code.
Code:
Private Sub CommandButton1_Click()
Range("A1:A10").sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal
End Sub
Thanks,
Pujo
 
Works great!
I do have a question if you have the time.

What is the theory of operation here, what doesn't it sort bringing the items to the top of the list.

Just trying to educate myself on this?
 
Upvote 0

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
The sort alphabetizes cells with text.
Spaces come before all other letters in Excel's alphabet.

So "John Smith" comes before "JohnSmith" , " smith" comes before "smith" and " " comes before any other string.

There are basicly three ways that a cell will appear blank:
1) it is truly blank and contains nothing.
2) it holds only spaces (e.g. " ")
3) it holds a formula that evalutes to either "" or spaces
(or 4) its formatted to show nothing, e.g. font color=white or number format returns nothing)

Each of those three is treated differently by sorting, ISBLANK and other Excel features.
It took me a conscious effort over time to switch from putting spaces in a cell to deleting the cell contents. That deliberate habit has payed off with shorter formulas.
 
Last edited:
Upvote 0
I never realized that even thou I clear the cell using "Space Bar"
that there was still data in the cell. So this makes sense. I guess I will have to be more careful when doing these things.

Thanks for the info.
Pujo
 
Upvote 0

Forum statistics

Threads
1,214,543
Messages
6,120,123
Members
448,947
Latest member
test111

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