+ Reply to Thread
Results 1 to 3 of 3

Function to return sequence from rank?

  1. #1
    Registered User
    Join Date
    04-04-2015
    Location
    Vancouver, Canada
    MS-Off Ver
    Office 365
    Posts
    88

    Function to return sequence from rank?

    Hi,
    I would like help on creating a function that returns:
    a sequence of cards ranked in order

    For example,
    In a deck of cards there are 13 ranks: A, K, Q, J, T, 9, 8, 7, 6, 5, 4, 3, 2
    A can be either high or low, A can be 13 or 1.
    Outputs them in two specific strings, "H" and "B".
    It's hard to explain, so I'll show by example.

    If H = "KQT" and B = "J98"
    then with function, it outputs: HHBHBB
    which is = KQJT98

    If H = "9632" and B = "KJ84"
    then with function, it outputs: BBHBHBHH
    which is = KJ986432

    If H = "53" and B = "AQ"
    then with function, it outputs: BBHH AND BHHB (I don't understand how that will be possible but obviously you guys are very good at this)
    which is AQ53 and also Q53A

    I think those examples explain better what I mean. Could you please help me?
    I don't even know where to start to be honest.

  2. #2
    Registered User
    Join Date
    05-21-2015
    Location
    Brazil
    MS-Off Ver
    Office 2010
    Posts
    11

    Re: Function to return sequence from rank?

    Repeated values will be replaced:

    Please Login or Register  to view this content.
    Last edited by VictorHPA; 05-21-2015 at 11:54 AM.

  3. #3
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Function to return sequence from rank?

    So this turned into kind of a Frankenstein, so it's a bit convoluted. I'll be happy to explain any of the code.

    A couple things:
    • you never said where the H and B string come from. They're hard-coded in right now, but you could do something like h = Range("A1").Value, or have an input box, or whatever
    • you never said what should happen in the case of a tie (like if both hands have a 5). I have it return a question mark, you can change that to whatever.

    Anyway, here's the ugly code:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] RANK duplicate numbers without missing in sequence
    By Simmo81 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 07-26-2014, 09:24 AM
  2. [SOLVED] Using the RANK function to rank decimal numbers
    By CRinne in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-29-2013, 02:14 PM
  3. [SOLVED] RANK function - to return data based on 2 different columns
    By Adsup01 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-30-2013, 08:17 PM
  4. Sum , Rank & Return
    By Xcentrik in forum Excel General
    Replies: 1
    Last Post: 08-30-2011, 12:45 AM
  5. return data for last record in sequence by row
    By tinkerbelle in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-23-2010, 09:39 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1