Ranking Strings
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 5 of 5

Thread: Ranking Strings

  1. #1
    Board Regular
    Join Date
    Dec 2011
    Posts
    343
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Ranking Strings

     
    There's a vba function called Application.Rank which can tell me the rank of a number amongst a range of other numbers.

    Is there a corresponding function that can do this with alpha strings?

    I want to rank something like this:

    { Ralph, Amanda, Chester }

    and have that give me the following rank:

    { 3, 1, 2 }

  2. #2
    Board Regular
    Join Date
    Dec 2004
    Posts
    2,217
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Ranking Strings

    Assuming you mean Ranking alphebetically, and if you can live with a helper column (which could be hidden, naturally), you could do something like this:

    Excel 2007
    ABCD
    1Ralph823
    2Amanda651
    3Chester672
    4………………………………………………………………

    Sheet1


    Worksheet Formulas
    CellFormula
    B1=CODE(LEFT(A1,1))
    C1=RANK(B1,$B$1:$B$3,1)
    B2=CODE(LEFT(A2,1))
    C2=RANK(B2,$B$1:$B$3,1)
    B3=CODE(LEFT(A3,1))
    C3=RANK(B3,$B$1:$B$3,1)
    Home: Unfortunately, no Excel at home at this time

    Work: XL07 in WinXP

    Any answer provided is based on one of these 2 environments, unless you specify otherwise.

    ------------------------------------------------

    Post your excel WS to the board - HTMLMaker Add-In

    ------------------------------------------------

    Always test any code posted on a COPY of your data.

  3. #3
    Board Regular T. Valko's Avatar
    Join Date
    May 2009
    Location
    Pittsburgh
    Posts
    16,623
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Ranking Strings

    Quote Originally Posted by Amateurhr View Post
    There's a vba function called Application.Rank which can tell me the rank of a number amongst a range of other numbers.

    Is there a corresponding function that can do this with alpha strings?

    I want to rank something like this:

    { Ralph, Amanda, Chester }

    and have that give me the following rank:

    { 3, 1, 2 }
    Like this...

    Sheet1

     AB
    2Ralph3
    3Amanda1
    4Chester2



    This formula entered in B2 and copied down:

    =COUNTIF(A$2:A$4,"<"&A2)+1
    .
    Biff
    Microsoft MVP - Excel

    Don't be afraid to use volatile functions or array formulas
    Tell us what version of Excel you're using
    KISS - Keep It Simple Stupid

  4. #4
    Board Regular
    Join Date
    Dec 2011
    Posts
    343
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Ranking Strings

    Thank you, I used Application.Countif and everything works great

  5. #5
    Board Regular T. Valko's Avatar
    Join Date
    May 2009
    Location
    Pittsburgh
    Posts
    16,623
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Ranking Strings

      
    Quote Originally Posted by Amateurhr View Post
    Thank you, I used Application.Countif and everything works great
    You're welcome. Thanks for the feedback!
    .
    Biff
    Microsoft MVP - Excel

    Don't be afraid to use volatile functions or array formulas
    Tell us what version of Excel you're using
    KISS - Keep It Simple Stupid

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com