Sorting alphabetically by function

Pauljj

Well-known Member
Joined
Mar 28, 2004
Messages
2,044
As with numbers you can sort using the function LARGE, is there a way you can do this alphabetically ??
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,726
Here's another way...

Assuming that A2:A10 contains the data...

B2:

=INDEX(A2:A10,MATCH(0,COUNTIF(A2:A10,">"&A2:A10),0))

B3, copied down:

=IF(COUNTIF(A$2:A$10,"<"&B2),INDEX(A$2:A$10,MATCH(COUNTIF($A$2:$A$10,">="&B2),COUNTIF(A$2:A$10,">"&A$2:A$10),0)),"")

Note that both formulas need to be confirmed with CONTROL+SHIFT+ENTER, not just ENTER.

Hope this helps!
 

bosco_yip

Well-known Member
Joined
Dec 2, 2002
Messages
1,938
Office Version
  1. 2019
Platform
  1. Windows
Or trying……

=IF(ROWS(B$2:B2)<=COUNTA(A:A),LOOKUP(2,1/(COUNTIF($A$2:$A$10,">"&$A$2:$A$10)=ROWS(B$2:B2)-1),$A$2:$A$10),"")

Regards
Bosco
 

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,726

ADVERTISEMENT

Actually, my solution returns a list of unique values, sorted alphabetically, in descending order. However, I should have offered the following solution instead...

B2, copied down:

=INDEX(A$2:A$10,MATCH(SMALL(COUNTIF(A$2:A$10,">"&A$2:A$10),ROWS(B$2:B2)),COUNTIF(A$2:A$10,">"&A$2:A$10),0))

...which lists duplicate values as well.

Hope this helps!
 

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,209
Here's another way...

Assuming that A2:A10 contains the data...

B2:

=INDEX(A2:A10,MATCH(0,COUNTIF(A2:A10,">"&A2:A10),0))

B3, copied down:

=IF(COUNTIF(A$2:A$10,"<"&B2),INDEX(A$2:A$10,MATCH(COUNTIF($A$2:$A$10,">="&B2),COUNTIF(A$2:A$10,">"&A$2:A$10),0)),"")

Note that both formulas need to be confirmed with CONTROL+SHIFT+ENTER, not just ENTER.

Hope this helps!

Some notes on the above formula system:

1] It cannot cope with numbers (both pos and neg) in the range to sort.
2] It eliminates duplicates under the assumption of like behavior as Data|Sort > Descending.
3] Although it's less volatile than the system in the link I quoted and it has lesser usage of cell memory, Full Calc and Microseconds per formula is higher.

N.B. I succeeded to eliminate the range housing rankings with Rank from the system in the link I quoted, the revised system becomes less volatile but Microseconds per formula doubles and it cannot cope with neg numbers in the range to sort.
 

vane0326

Well-known Member
Joined
Aug 29, 2004
Messages
819

ADVERTISEMENT

Input formula in cell b2 and copied down.


=IF(COUNTA($A$1:$A$100)>ROW()-ROW($A$1),INDEX($A$1:$A$100,MATCH(LARGE(COUNTIF($A$1:$A$100,">"&$A$1:$A$100),ROW()-ROW($A$1)+1),COUNTIF($A$1:$A$100,">"&$A$1:$A$100),0)),"")

Formula is an-array must hold down:

Ctrl,Shift,Enter


Edit: I changed the formula because it did not account for duplicates this formula will.
 

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,726
Here's another way...

Assuming that A2:A10 contains the data...

B2:

=INDEX(A2:A10,MATCH(0,COUNTIF(A2:A10,">"&A2:A10),0))


B3, copied down:

=IF(COUNTIF(A$2:A$10,"<"&B2),INDEX(A$2:A$10,MATCH(COUNTIF($A$2:$A$10,">="&B2),COUNTIF(A$2:A$10,">"&A$2:A$10),0)),"")

Note that both formulas need to be confirmed with CONTROL+SHIFT+ENTER, not just ENTER.

Hope this helps!

Some notes on the above formula system:

1] It cannot cope with numbers (both pos and neg) in the range to sort.

I was under the impression that the range would contain only alpha-characters, but of course I could be wrong. :)

2] It eliminates duplicates under the assumption of like behavior as Data|Sort > Descending.

Yes, for some reason I was thinking unique values, hence my follow-up post... :oops:

3] Although it's less volatile than the system in the link I quoted and it has lesser usage of cell memory, Full Calc and Microseconds per formula is higher.

Interesting, although I wasn't aware that it was at all volatile. I don't see any volatile functions, unless I'm missing something. Can you please shed some light?

N.B. I succeeded to eliminate the range housing rankings with Rank from the system in the link I quoted, the revised system becomes less volatile but Microseconds per formula doubles and it cannot cope with neg numbers in the range to sort.

Very interesting...
 

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,209
Here's another way...

Assuming that A2:A10 contains the data...

B2:

=INDEX(A2:A10,MATCH(0,COUNTIF(A2:A10,">"&A2:A10),0))


B3, copied down:

=IF(COUNTIF(A$2:A$10,"<"&B2),INDEX(A$2:A$10,MATCH(COUNTIF($A$2:$A$10,">="&B2),COUNTIF(A$2:A$10,">"&A$2:A$10),0)),"")

Note that both formulas need to be confirmed with CONTROL+SHIFT+ENTER, not just ENTER.

Hope this helps!

Some notes on the above formula system:

1] It cannot cope with numbers (both pos and neg) in the range to sort.

I was under the impression that the range would contain only alpha-characters, but of course I could be wrong. :)

Ignoring generality is admissible if the system has a signicant superiority over one that is (more) general. :LOL:

2] It eliminates duplicates under the assumption of like behavior as Data|Sort > Descending.

Yes, for some reason I was thinking unique values, hence my follow-up post... :oops:

I didn't check the modification.

3] Although it's less volatile than the system in the link I quoted and it has lesser usage of cell memory, Full Calc and Microseconds per formula is higher.

Interesting, although I wasn't aware that it was at all volatile. I don't see any volatile functions, unless I'm missing something. Can you please shed some light?

Quoting from Charles Williams's site:

"FastExcel measures Workbook Volatility by comparing the time for a Recalculation to the time for a full calculation, and allows you to measure worksheet volatility by comparing the sheet recalculate time with the sheet full calculate time."

Volatile functions aggravates the volatility score for:

"A Volatile Function in a formula in a cell is always recalculated at each recalculation even if it does not appear to have any changed precedents."
 

Pauljj

Well-known Member
Joined
Mar 28, 2004
Messages
2,044
I am amazed and very grateful for all your responses, thank you so much
 

Forum statistics

Threads
1,141,628
Messages
5,707,499
Members
421,511
Latest member
mgroah1

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
Top