Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
cdavidson
 
Posts: n/a
Default Ranking Alphabetically

I'll use a simple example...

I have 5 words I need to rank in ascending order, alphabetically.

Carrot
Peach
Apple
Salad
Banana


I would like the rank function to produce the following results:

Rank Name
------ -------
1 Apple
2 Banana
3 Carrot
4 Peach
5 Salad

How please? Many thanks.
  #2   Report Post  
Domenic
 
Posts: n/a
Default

Assuming that A1:A5 contains your data, try...

B1, copied down:

=INDEX($A$1:$A$5,MATCH(SMALL(COUNTIF($A$1:$A$5,"<" &$A$1:$A$5),ROWS($B$1:B
1)),COUNTIF($A$1:$A$5,"<"&$A$1:$A$5),0))

....confirmed with CONTROL+SHIFT+ENTER, not just ENTER.

C1, copied down:

=COUNTIF($B$1:$B$5,"<"&B1)+1

Hope this helps!

In article ,
cdavidson wrote:

I'll use a simple example...

I have 5 words I need to rank in ascending order, alphabetically.

Carrot
Peach
Apple
Salad
Banana


I would like the rank function to produce the following results:

Rank Name
------ -------
1 Apple
2 Banana
3 Carrot
4 Peach
5 Salad

How please? Many thanks.

  #3   Report Post  
Bernie Deitrick
 
Posts: n/a
Default

You could simply sort the column ascending.

If your values are in a1:a5, then the formula

=SUMPRODUCT((A1$A$1:$A$5)*1)+1

copied down for 5 rows will give the ranking.

--
HTH,
Bernie
MS Excel MVP


"cdavidson" wrote in message
...
I'll use a simple example...

I have 5 words I need to rank in ascending order, alphabetically.

Carrot
Peach
Apple
Salad
Banana


I would like the rank function to produce the following results:

Rank Name
------ -------
1 Apple
2 Banana
3 Carrot
4 Peach
5 Salad

How please? Many thanks.



  #4   Report Post  
B. R.Ramachandran
 
Posts: n/a
Default

Bernie,
The formula you have suggested is extremely elegant (in the way it works).
Regards,
B. R. Ramachandran

"Bernie Deitrick" wrote:

You could simply sort the column ascending.

If your values are in a1:a5, then the formula

=SUMPRODUCT((A1$A$1:$A$5)*1)+1

copied down for 5 rows will give the ranking.

--
HTH,
Bernie
MS Excel MVP


"cdavidson" wrote in message
...
I'll use a simple example...

I have 5 words I need to rank in ascending order, alphabetically.

Carrot
Peach
Apple
Salad
Banana


I would like the rank function to produce the following results:

Rank Name
------ -------
1 Apple
2 Banana
3 Carrot
4 Peach
5 Salad

How please? Many thanks.




  #5   Report Post  
Bernie Deitrick
 
Posts: n/a
Default

B. R.,

Thanks. I would like to take credit for it, but I learned that technique a looooong time ago from
people who are much smarter <vbg

Bernie
MS Excel MVP

Bernie,
The formula you have suggested is extremely elegant (in the way it works).
Regards,
B. R. Ramachandran

"Bernie Deitrick" wrote:

You could simply sort the column ascending.

If your values are in a1:a5, then the formula

=SUMPRODUCT((A1$A$1:$A$5)*1)+1





  #6   Report Post  
B. R.Ramachandran
 
Posts: n/a
Default

Bernie,
This is a follow-up of my previous response.
If there is a tie, (e.g., banana, apple, banana, grapes), the formula would
rank them 2,1,2,and 4 respectively. I am curious, how you would modify the
formula to make grapes rank 3 (and not 4)?
Regards,
B.R. Ramachandran

"Bernie Deitrick" wrote:

You could simply sort the column ascending.

If your values are in a1:a5, then the formula

=SUMPRODUCT((A1$A$1:$A$5)*1)+1

copied down for 5 rows will give the ranking.

--
HTH,
Bernie
MS Excel MVP


"cdavidson" wrote in message
...
I'll use a simple example...

I have 5 words I need to rank in ascending order, alphabetically.

Carrot
Peach
Apple
Salad
Banana


I would like the rank function to produce the following results:

Rank Name
------ -------
1 Apple
2 Banana
3 Carrot
4 Peach
5 Salad

How please? Many thanks.




  #7   Report Post  
Bernie Deitrick
 
Posts: n/a
Default

I'm not aware of a technique using a single worksheetfunction that can do that - I would write a
User-Defined-Function, or use multiple columns of formulas.

HTH,
Bernie
MS Excel MVP


"B. R.Ramachandran" wrote in message
...
Bernie,
This is a follow-up of my previous response.
If there is a tie, (e.g., banana, apple, banana, grapes), the formula would
rank them 2,1,2,and 4 respectively. I am curious, how you would modify the
formula to make grapes rank 3 (and not 4)?
Regards,
B.R. Ramachandran

"Bernie Deitrick" wrote:

You could simply sort the column ascending.

If your values are in a1:a5, then the formula

=SUMPRODUCT((A1$A$1:$A$5)*1)+1

copied down for 5 rows will give the ranking.

--
HTH,
Bernie
MS Excel MVP


"cdavidson" wrote in message
...
I'll use a simple example...

I have 5 words I need to rank in ascending order, alphabetically.

Carrot
Peach
Apple
Salad
Banana


I would like the rank function to produce the following results:

Rank Name
------ -------
1 Apple
2 Banana
3 Carrot
4 Peach
5 Salad

How please? Many thanks.






  #8   Report Post  
Domenic
 
Posts: n/a
Default

Assuming that A1:A4 contains your data, try...

B1, copied down:

=SUM(IF(A1$A$1:$A$4,1/COUNTIF($A$1:$A$4,$A$1:$A$4)))+1

....confirmed with CONTROL+SHIFT+ENTER.

Hope this helps!

In article ,
"B. R.Ramachandran" wrote:

Bernie,
This is a follow-up of my previous response.
If there is a tie, (e.g., banana, apple, banana, grapes), the formula would
rank them 2,1,2,and 4 respectively. I am curious, how you would modify the
formula to make grapes rank 3 (and not 4)?
Regards,
B.R. Ramachandran

  #9   Report Post  
B. R.Ramachandran
 
Posts: n/a
Default

Bernie,
That's what I thought.
Thanks for your prompt response.
B.R.Ramachandran

"Bernie Deitrick" wrote:

I'm not aware of a technique using a single worksheetfunction that can do that - I would write a
User-Defined-Function, or use multiple columns of formulas.

HTH,
Bernie
MS Excel MVP


"B. R.Ramachandran" wrote in message
...
Bernie,
This is a follow-up of my previous response.
If there is a tie, (e.g., banana, apple, banana, grapes), the formula would
rank them 2,1,2,and 4 respectively. I am curious, how you would modify the
formula to make grapes rank 3 (and not 4)?
Regards,
B.R. Ramachandran

"Bernie Deitrick" wrote:

You could simply sort the column ascending.

If your values are in a1:a5, then the formula

=SUMPRODUCT((A1$A$1:$A$5)*1)+1

copied down for 5 rows will give the ranking.

--
HTH,
Bernie
MS Excel MVP


"cdavidson" wrote in message
...
I'll use a simple example...

I have 5 words I need to rank in ascending order, alphabetically.

Carrot
Peach
Apple
Salad
Banana


I would like the rank function to produce the following results:

Rank Name
------ -------
1 Apple
2 Banana
3 Carrot
4 Peach
5 Salad

How please? Many thanks.






  #10   Report Post  
Bernd Plumhoff
 
Posts: n/a
Default

Hello,

a stable sort which would leave identical items in it's original order (I
assume the data in column A):

B1:

=COUNTIF($A:$A,"<"&A1)+COUNTIF($A$1:A1,A1)

C1:

=INDEX(A:A,MATCH(ROW(),B:B,FALSE))

Copy down...

Regards,
Bernd
--
Excel 2002


  #11   Report Post  
B. R.Ramachandran
 
Posts: n/a
Default

Excellent. The 1/COUNTIF idea is very clever.
B.R. Ramachandran

"Domenic" wrote:

Assuming that A1:A4 contains your data, try...

B1, copied down:

=SUM(IF(A1$A$1:$A$4,1/COUNTIF($A$1:$A$4,$A$1:$A$4)))+1

....confirmed with CONTROL+SHIFT+ENTER.

Hope this helps!

In article ,
"B. R.Ramachandran" wrote:

Bernie,
This is a follow-up of my previous response.
If there is a tie, (e.g., banana, apple, banana, grapes), the formula would
rank them 2,1,2,and 4 respectively. I am curious, how you would modify the
formula to make grapes rank 3 (and not 4)?
Regards,
B.R. Ramachandran


  #12   Report Post  
Martin P
 
Posts: n/a
Default

If the list is in A1 to A7 I would have in B1:
=SUMPRODUCT(--($A$1:$A1=$A1))
and in B2
=SUMPRODUCT(--($A$1:$A$7<=$A1),--($B$1:$B$7=1))
Then copy to the seventh row.

"B. R.Ramachandran" wrote:

Bernie,
This is a follow-up of my previous response.
If there is a tie, (e.g., banana, apple, banana, grapes), the formula would
rank them 2,1,2,and 4 respectively. I am curious, how you would modify the
formula to make grapes rank 3 (and not 4)?
Regards,
B.R. Ramachandran

"Bernie Deitrick" wrote:

You could simply sort the column ascending.

If your values are in a1:a5, then the formula

=SUMPRODUCT((A1$A$1:$A$5)*1)+1

copied down for 5 rows will give the ranking.

--
HTH,
Bernie
MS Excel MVP


"cdavidson" wrote in message
...
I'll use a simple example...

I have 5 words I need to rank in ascending order, alphabetically.

Carrot
Peach
Apple
Salad
Banana


I would like the rank function to produce the following results:

Rank Name
------ -------
1 Apple
2 Banana
3 Carrot
4 Peach
5 Salad

How please? Many thanks.




  #13   Report Post  
cdavidson
 
Posts: n/a
Default

Thank you Bernie, your formula worked perfectly for my simple example.
However, my apologies, I now realize I should have mentioned that my real
data set contains quite a few blank cells in the column of data I am trying
to rank (see revised example below). I need to exclude the blank cells from
the rankings, so can I ask you to offer an enhance formula to accomplish
this? Many thanks.


A1: Carrot
A2: Peach
A3:
A4: Apple
A5: Salad
A6:
A7: Banana


I would like the rank function to produce the following results:

Rank Name
------ -------
1 Apple
2 Banana
3 Carrot
4 Peach
5 Salad







"Bernie Deitrick" wrote:

You could simply sort the column ascending.

If your values are in a1:a5, then the formula

=SUMPRODUCT((A1$A$1:$A$5)*1)+1

copied down for 5 rows will give the ranking.

--
HTH,
Bernie
MS Excel MVP


"cdavidson" wrote in message
...
I'll use a simple example...

I have 5 words I need to rank in ascending order, alphabetically.

Carrot
Peach
Apple
Salad
Banana


I would like the rank function to produce the following results:

Rank Name
------ -------
1 Apple
2 Banana
3 Carrot
4 Peach
5 Salad

How please? Many thanks.




  #14   Report Post  
Bernie Deitrick
 
Posts: n/a
Default

In B1, use the formula

=IF(A1="","",SUMPRODUCT((A1$A$1:$A$7)*($A$1:$A$7< ""))+1)

and copy down to match your list.

HTH,
Bernie
MS Excel MVP


"cdavidson" wrote in message
...
Thank you Bernie, your formula worked perfectly for my simple example.
However, my apologies, I now realize I should have mentioned that my real
data set contains quite a few blank cells in the column of data I am trying
to rank (see revised example below). I need to exclude the blank cells from
the rankings, so can I ask you to offer an enhance formula to accomplish
this? Many thanks.


A1: Carrot
A2: Peach
A3:
A4: Apple
A5: Salad
A6:
A7: Banana


I would like the rank function to produce the following results:

Rank Name
------ -------
1 Apple
2 Banana
3 Carrot
4 Peach
5 Salad







"Bernie Deitrick" wrote:

You could simply sort the column ascending.

If your values are in a1:a5, then the formula

=SUMPRODUCT((A1$A$1:$A$5)*1)+1

copied down for 5 rows will give the ranking.

--
HTH,
Bernie
MS Excel MVP


"cdavidson" wrote in message
...
I'll use a simple example...

I have 5 words I need to rank in ascending order, alphabetically.

Carrot
Peach
Apple
Salad
Banana


I would like the rank function to produce the following results:

Rank Name
------ -------
1 Apple
2 Banana
3 Carrot
4 Peach
5 Salad

How please? Many thanks.






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
i want to list all my cd's alphabetically tangerine62 New Users to Excel 4 May 29th 05 12:18 AM
Numbers used for Ranking Lowkey Excel Worksheet Functions 4 May 27th 05 11:26 PM
sorting names alphabetically when names may start with numbers John Smith Excel Discussion (Misc queries) 3 May 11th 05 08:06 PM
Ranking Using Grand Total nostalgie Excel Discussion (Misc queries) 0 April 9th 05 03:27 PM
Ranking Thrava Excel Discussion (Misc queries) 6 February 15th 05 10:49 AM


All times are GMT +1. The time now is 01:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"