Sort Capitalized words ahead of lower case

Chief_Fred

New Member
Joined
Apr 20, 2012
Messages
22
I've got a 96000 line spreadsheet with individual words or abbreviations in each cell of the first column. I need to sort it with numbers first, then Capitalized words, then lowercase words. The numbers aren't an issue but sorting the Caps first then lower case without getting words that have a cap in the middle is frying my tiny brain. Originally I dug around here and found a search for caps that returned a True/False then sorted the columns on the result. =MIN(--EXACT(Dict3,LOWER(Dict3)))=0 Then I found that I had abbreviations in the list like cGy and eV or cGMB that incorrectly showed up as true but weren't. Now I need a modification or a better answer. I tried a fw dozen things but obviously I'm barking up the wrong functions.:confused:

Help please

Fred
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
This returns true or false and should produce TRUE for any text beginning with a capital letter.
Code:
=IF(AND(ISERROR(FIND(UPPER(A1),A1,1)),ISERROR(FIND(PROPER(A1),A1,1))),FALSE,TRUE)
 
Upvote 0
Chief_Fred,

Does this help?

Create a helper column. In this case ColB.
Add formula as below and copy down as required.
Set up a 2 level sort sorting col B first col A second.

Sheet1

*AB
111
211
361
4****2
5Fred2
6Harry2
7Harry2
8Name2
9Tam2
10Tim2
11Tom2
12tam3
13tim3
14tiM3
15tom3

<COLGROUP><COL style="WIDTH: 30px; FONT-WEIGHT: bold"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"></COLGROUP><TBODY>
</TBODY>

Spreadsheet Formulas
CellFormula
B1=IF(ISNUMBER(A1),1,IF(ISERROR(FIND(UPPER(LEFT(A1,1)),A1,1)),3,2))

<TBODY>
</TBODY>

<TBODY>
</TBODY>


Excel tables to the web >> Excel Jeanie Html" target="_blank"> Excel Jeanie HTML 4
 
Upvote 0
JoeMo, Thanks but it doesn't every time for some reason. Cells containing A1c, Aaron's, Aarskog's -it appears anything with an apostrophe shoes false which is moot as they have to be weeded out they told me today anyway - AastromReplicell, AlgiDERM, AllerNaze . . for example show false.
 
Last edited:
Upvote 0
Chief_Fred,

Does this help?

Create a helper column. In this case ColB.
Add formula as below and copy down as required.
Set up a 2 level sort sorting col B first col A second.

Sheet1

*AB
111
211
361
4****2
5Fred2
6Harry2
7Harry2
8Name2
9Tam2
10Tim2
11Tom2
12tam3
13tim3
14tiM3
15tom3

<tbody>
</tbody>

Spreadsheet Formulas
CellFormula
B1=IF(ISNUMBER(A1),1,IF(ISERROR(FIND(UPPER(LEFT(A1,1)),A1,1)),3,2))

<tbody>
</tbody>

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie Html" target="_blank"> Excel Jeanie HTML 4

Ype, 99.99999% perfect! The exceptions was the cells containing data like this - 1,2:5,6-dibenzanthracene - which should have been a 1 but returned a 2. Fortunately only about a dozen of those cells exist and excell put them at the top of the "2" list.
Thanks a bunch!

Fred
 
Upvote 0
How about this
=1+AND(64 < CODE(A1&"x"), CODE(A1&"x") < 91)+2*AND(96 < CODE(A1&"X"), CODE(A1&"X") < 123)
 
Upvote 0
Ype, 99.99999% perfect! The exceptions was the cells containing data like this - 1,2:5,6-dibenzanthracene - which should have been a 1 but returned a 2. Fortunately only about a dozen of those cells exist and excell put them at the top of the "2" list.

If the leading character can only be a letter or digit (and nothing else), then give this formula a try instead...

=INT(CODE(LEFT(A1))/32.1)
 
Upvote 0
Chief_Fred,

It would be nice to find that extra 0.00001%.

Rick's formula will let you down if you were to have certain unusual leading characters such as ~
Mike's is fine other than the fact that it will resolve to 1 for a blank cell in A and this will result in any such blank being sorted to the bottom of the 1's.

This can be fixed by modifying as follows..
=1+AND(64 < CODE(A1&"x"), CODE(A1&"x") < 91)+2*AND(96 < CODE(A1&"X"), CODE(A1&"X") < 123)+3*ISBLANK(A1)

so that a blank resolves to 4 and is sorted to the bottom.
 
Upvote 0
Rick's formula will let you down if you were to have certain unusual leading characters such as ~
Which is why I went out of my way to say...
"If the leading character can only be a letter or digit (and nothing else)..."

Rick's formula will let you down if you were to have certain unusual leading characters such as ~
Mike's is fine other than the fact that it will resolve to 1 for a blank cell in A and this will result in any such blank being sorted to the bottom of the 1's.

This can be fixed by modifying as follows..
=1+AND(64 < CODE(A1&"x"), CODE(A1&"x") < 91)+2*AND(96 < CODE(A1&"X"), CODE(A1&"X") < 123)+3*ISBLANK(A1)

so that a blank resolves to 4 and is sorted to the bottom.
What about the the ~ and other non-letters, non-digits? Fred did not say where such characters should go assuming it were possible for them to be the leading character, but your formula makes them all 1, the same as the digits... won't that make text starting with those characters and text starting with the digits possibly intermingle with each other after being sorted depending on their original order of appearance? So then, I guess we will have to wait for Fred to find out whether non-digits, non-letters are possible starting characters or not and, if so, exactly what he wants done with them. In the meantime, the only place my formula falls down, then, is for blank cells, which is easily fixed using standard means...

=IF(A1="",4,INT(CODE(LEFT(A1))/32.1))
 
Upvote 0
Rick,
Rick's formula will let you down if you were to have certain unusual leading characters such as ~

The comment was made purely as confirmation of your own statement. It was certainly not intended to be a put down.

I got the impression from Fred's post #5 that some of his leading characters on his exceptions could be - , :preceding a number. On reflection they are probably just separators in his post and I am just an idiot;)
I had noticed that your formula would return 1 for a lot of common non-letter, non-digits but not for all, such as ~ which returns 3. Mike's formula,however, returns 1 for all which I thought put them in good shape for the sort.
Perhaps Fred will clarify.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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