+ Reply to Thread
Results 1 to 5 of 5

Blackjack spreadsheet

  1. #1
    Registered User
    Join Date
    04-09-2010
    Location
    Las Vegas, NV
    MS-Off Ver
    Excel 2003
    Posts
    3

    Blackjack spreadsheet

    I'm making a spreadsheet for tracking and counting card values for the game of Blackjack.

    I have a range of cells such as (K14:R15). Some of those cells could contain any number 2 through 9. But, I also need some of those cells to possibly contain the upper case letter "A" and some of those cells to possibly contain the lower case letter "a" and some of those cells to possibly contain either the upper case letters K, Q, or J. Here is why:

    If a cell in that range contains the letter K, or Q or J, I need the value of those cells to each equal 10. Of course, the Ace can either be valued as 1 or 11, so, to make the differentiation between the two, if a cell in that range has an upper case letter A then I need that cell to equal the value of 11. If a cell in that range has a lower case letter "a" then I need that cell to equal the value of 1. Then, finally, I want to sum the range K14:R15


    So, for example:

    ....K L M N O P Q R
    14 2 4 7 9 A 3 4 a
    15 A K 8 J 5 a 3 Q

    The sum (K14:R15) should = 99

    Normally, adding the cells would be easy enough but the problem is in the letters. In the above example; the value of cells R14 and P15 need to equal 1 and the value of cells O14 and K15 need to equal 11 and the value of cells L15, N15 and R15 need to equal 10.

    Is this even possible? Is there a formula for my problem or do you recommend code? Unfortunately, I know little about formulas and even less about code.


    Thanks for your time,


    Rob
    Last edited by Wildcard27; 12-04-2015 at 07:13 AM.

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,082

    Re: Blackjack spreadsheet

    =SUM(IF(ISNUMBER(K14:R15),K14:R15,LOOKUP(CODE(K14:R15),{65,74,75,81,97},{11,10,10,10,1})))
    Array formula, use Ctrl-Shift-Enter

    This uses the rank of each card if it is numeric otherwise it uses the ASCII code of the character to distinguish between "a" and "A" which is the major problem
    Do not change the order of the values in the LOOKUP, the numbers have to be in ascending order
    Last edited by Special-K; 12-04-2015 at 08:14 AM.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Registered User
    Join Date
    04-09-2010
    Location
    Las Vegas, NV
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Blackjack spreadsheet

    Special-K,

    Thank you for your help with my issue. The solution worked great as long as every cell in my range is populated. I did not take into account that there would be a problem if some of the cells did not contain a value. My apologies, here is what I failed to mention in my first post;

    Since each cell in my range, K14:r15 actually represents a card value, the number of populated cells will vary due to the amount of cards a person needs to draw per hand. For instance, some hands will only need two cards because the player was dealt a blackjack, so the other 14 cells will be empty, or, sometimes a player can draw to a 7 card 21 so, 9 of the cells will not contain a value.

    What do I do if some of those cells in K14:R15 do not have an entry? Can I still use a variation of the formula you provided?

    Thank you for your continued assistance,

    Rob

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,049

    Re: Blackjack spreadsheet

    Without getting too involved in SK's formula, can you wrap it in IF(ISERROR)?
    excel before 2007...
    =if(iserror(SUM(IF(ISNUMBER(K14:R15),K14:R15,LOOKUP(CODE(K14:R15),{65,74,75,81,97},{11,10,10,10,1}))),"",=SUM(IF(ISNUMBER(K14:R15),K14:R15,LOOKUP(CODE(K14:R15),{65,74,75,81,97},{11,10,10,10,1})))
    )

    excel 2007 and later...
    =IFERROR(SUM(IF(ISNUMBER(K14:R15),K14:R15,LOOKUP(CODE(K14:R15),{65,74,75,81,97},{11,10,10,10,1}))),"")
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Registered User
    Join Date
    04-09-2010
    Location
    Las Vegas, NV
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Blackjack spreadsheet

    FDibbins,

    Thank you for your assistance. I am using Excel 2010.

    Your formula, ...excel 2007 and later...
    =IFERROR(SUM(IF(ISNUMBER(K14:R15),K14:R15,LOOKUP(CODE(K14:R15),{65,74,75,81,97},{11,10,10,10,1}))),"") hides the sum if there are empty cells in my range.

    To make sure I'm being clear (I don't want to waste anyone's time), Special-K's formula worked if all cells in my range are populated. If there are any empty cells, it returns #VALUE. Your formula hid the #VALUE in the sum cell when there were empty cells in my range.

    Any other ideas?


    Rob
    Last edited by Wildcard27; 12-04-2015 at 11:53 PM.

+ 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. Blackjack simulation in Excel
    By G Love in forum Excel General
    Replies: 8
    Last Post: 02-24-2025, 11:49 AM
  2. Running total for a blackjack trainer
    By romangreco in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-05-2015, 09:37 PM
  3. rearrange specific data on spreadsheet to match the rest of the spreadsheet. Is it possibl
    By baby_kay_2003 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 11-04-2014, 07:46 PM
  4. Blackjack Odds Generator
    By bluerog in forum The Water Cooler
    Replies: 2
    Last Post: 05-26-2013, 03:25 AM
  5. Blackjack spreadsheet
    By Rick-O-Shay in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-08-2012, 02:47 PM
  6. Excel spreadsheet holiday to Outlook Shared Calendar and update spreadsheet
    By tigerdel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-25-2012, 06:04 AM
  7. Replies: 1
    Last Post: 02-08-2005, 06:06 AM

Tags for this Thread

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