+ Reply to Thread
Results 1 to 26 of 26

Multiple dice roller (d6) with two cells and one formula?

  1. #1
    Registered User
    Join Date
    10-17-2014
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2010
    Posts
    3

    Multiple dice roller (d6) with two cells and one formula?

    I am planning on making a sufficient dice generator sheet for my excel document. But so far, I am only able to create one dice generator per cell. I want to create the interactive option of throwing 1 to 20 times the same dice and have the result in only two cells (the number of dices, and the sum). And that option should be able for more than one type of dice (standard roleplaying set). Basically, I want to be able to replicate the RANDBETWEEN function. So, A2 being my number of dice column: if A2=x, then RANDBETWEEN repeated X times (and not X*RANDBETWEEN, which only multiplies x times the first dice throw). I cannot believe that what I want to do is not possible on excel. Anyone can help?


    My table has a column for the number of dices I want to throw, the type of dice, and then the sum: number, type, sum.

    I was able to use an IF function to be able to roll up to three dice at a time and add the total in the last column. But it says I have too much variable when I try to get past 3 dice at the same time. Also, I do this while using the RANDBETWEEN function quite primitively. Here's what the equation looks like (RANDBETWEEN=ALEA.ENTRE.BORNES since my version is french against my will):

    =IF(A2=1,ALEA.ENTRE.BORNES(1,4), SI(A2=2,ALEA.ENTRE.BORNES(1,4)+ALEA.ENTRE.BORNES(1,4)))

    I will look up vlookup, concatenation and nested ifs, but I am looking more precisely for something that will happen directly through the formula in the cell, and not referencing other cells or tables (like vlookup seems to do).

    Basically, I want to be able to replicate the RANDBETWEEN function. So, A2 being my number of dice columb: if A2=x, then XRANDBETWEEN (and not X*RANDBETWEEN, which only multiplies x times the first dice throw). I cannot believe that what I want to do is not possible on excel. Anyone can help?

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Multiple dice roller (d6) with two cells and one formula?

    What a fabulous question. I can make a macro/UDF that does this for you in my sleep, and we may have to resort to that. In the meantime I've called some other eyes to this question to see if anyone can pickup on a workable formula-only approach. I'm stumped so far. Everything I try, no matter how creative, ultimately just multiplies the original two dice roll by the number of rolls requested.

    Still scratching my head.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Multiple dice roller (d6) with two cells and one formula?

    It's long but it caters for up to 20 dice rolls

    put the number of dice rolls in B3

    Please Login or Register  to view this content.
    Last edited by Crooza; 10-18-2014 at 05:58 AM.
    Happy with my advice? Click on the * reputation button below

  4. #4
    Registered User
    Join Date
    04-09-2013
    Location
    Minnesota, USA
    MS-Off Ver
    Excel 365
    Posts
    29

    Re: Multiple dice roller (d6) with two cells and one formula?

    A little but here you go
    Attached Files Attached Files

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Multiple dice roller (d6) with two cells and one formula?

    The thing that makes this so difficult is your insistence that this be done in a single cell. With a million rows and 10's of thousands of columns, it seems overly stingy to insist on a single cell formula. What is behind your desire to have a single cell? Helper cells containing single RANDBETWEEN() functions could be put in a hidden column, and the X number of cells added up fairly easily.

    Has anyone tried an iterative solution? Put =RANDBETWEEN(1,6) in A1. B1=A1+B1. Enable iteration and set max iteration to X. Put 0 in A2 and copy B1 into B2, to give you an easy way to reset the calculation. With max iteration set to the desired X, copy B2 into B1 to get your result.

    The main difficulty is that it is less convenient to change X, and the hassle of resetting the summation, since the summation will continue to sum up with each calculation event until you reset it (manual calculation might be desirable, so it will only calculate when you command it).
    Attached Files Attached Files
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Multiple dice roller (d6) with two cells and one formula?

    How about using a helper column?

    Row\Col
    A
    B
    C
    1
    min
    2
    1
    B2: Input
    3
    max
    4
    6
    B4: Input
    5
    value
    6
    5
    B6: =SUM(B5, RANDBETWEEN($B$2, $B$4))
    7
    7
    8
    11
    9
    15
    10
    16
    11
    19
    12
    23
    13
    29
    14
    33
    15
    34
    16
    35
    17
    40
    18
    44
    19
    45
    20
    46
    21
    48
    22
    51
    23
    52
    24
    54
    25
    58
    26
    27
    dice
    value
    28
    5
    16
    B28: =INDEX($B$6:$B$25, A28)
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,293

    Re: Multiple dice roller (d6) with two cells and one formula?

    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

  8. #8
    Registered User
    Join Date
    10-17-2014
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Multiple dice roller (d6) with two cells and one formula?

    Wow, thank you all for your fast replies. I had spent most of my last day on this. I will see all your suggestions and come back on the ones who worked for me.

    My insistence on it being done in a single cell is mostly because I'm pretty sure it can be done (and trying to figure out how) and that I'm trying to make my whole document as simple as it can be (the dice roller being only one sheet of it) since I'm making it for people who probably will not know how to work on excel. And so, I'm hoping it can be simple, compact (reduced the most efficient minimum) and thus, easily modifiable in case have future problems with it (and so my reluctance on macros).

  9. #9
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Multiple dice roller (d6) with two cells and one formula?

    I'm pretty sure it can be done (and trying to figure out how)
    Considering what I have seen from those who have responded and those who have chosen not to respond because they are "not interested", the evidence I see is "it might be possible, but it is not a desirable approach" to this problem. If you also want it "easily modfiable", I don't think a single cell formula is really the answer here.

    I'm hoping it can be simple, compact (reduced the most efficient minimum) and thus, easily modifiable in case have future problems with it (and so my reluctance on macros).
    If you really do not want to use a helper block to hold the individual random numbers, I think the easiest way to meet all of these requirements is going to be a UDF (user-defined function-- VBA function procedure called from the spreadsheet). A UDF for this will be simple (a single For...Next loop should do the trick), easy to understand and modify, forward and backward compatible within Excel over many versions (though it will not work in other spreadsheet applications), compact, and efficient.

    I guess what I am suggesting at this point -- reconsider your requirements and restrictions in order to open up easier possibilities.

  10. #10
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Multiple dice roller (d6) with two cells and one formula?

    Array-enter:

    =SUM(RANDBETWEEN(IF(1,ROW(INDIRECT("1:"&A2))/ROW(INDIRECT("1:"&A2))),IF(1,ROW(INDIRECT("1:"&A2))/ROW(INDIRECT("1:"&A2))*6)))

    for example.
    Remember what the dormouse said
    Feed your head

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Multiple dice roller (d6) with two cells and one formula?

    DUDE! That is IT! (cheer)

    So, the only caveat here is the number you put in A2 is the "number of dice to roll". So if you want 20 rolls of 2 dice, put 40 in A2. Brilliance!

  12. #12
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Multiple dice roller (d6) with two cells and one formula?

    Oh yes - thanks, I should have clarified that!

  13. #13
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Multiple dice roller (d6) with two cells and one formula?

    surely if you have one die and one roll then it can only be 1 to 6, if you have 2 dice then then total can only be 2 to 12
    so sum 20 rolls of 1 die randomly will be from 20 to 120
    from 2 dice min 2 to max 12 would sum between 80 to 240 or am i missing something?
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  14. #14
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Multiple dice roller (d6) with two cells and one formula?

    Very Nice.

  15. #15
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Multiple dice roller (d6) with two cells and one formula?

    Roll the dice without macro
    Attached Files Attached Files
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  16. #16
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Multiple dice roller (d6) with two cells and one formula?

    Quote Originally Posted by martindwilson View Post
    surely if you have one die and one roll then it can only be 1 to 6, if you have 2 dice then then total can only be 2 to 12
    so sum 20 rolls of 1 die randomly will be from 20 to 120
    from 2 dice min 2 to max 12 would sum between 80 to 240 or am i missing something?
    You're missing the probability of rolls, Martin.

  17. #17
    Registered User
    Join Date
    10-17-2014
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Multiple dice roller (d6) with two cells and one formula?

    I took shg and MrShorty's advice, and used another column to make the calculations instead. Except for those 30 rows of my masked column, it can all fit into two cells: one for number, one for the type of dice (sides). I think it was suggested by someone on this thread, but I used this equation on 30 cells in a free column (A9 being the cell for number of dice, B9 for the sides of the dice):

    =IF(LINE(A1)>A9,"",RANBETWEEN(1,B9))
    =IF(LINE(A2)>A9,"",RANBETWEEN(1,B9))
    =IF(LINE(A3)>A9,"",RANBETWEEN(1,B9))...

    The result is satisfying, at the very least. And it will be probably what I use for the moment.

    1) As for the median equation offered by crooza, it actually did the job.

    =MEDIAN(RANDBETWEEN(1,6),(B3-0)*10,0)+MEDIAN(RANDBETWEEN(1,6),(B3-1)*10,0)

    But from the tests I've done, I'm pretty sure the mathematical randomness is skewed around the center (i.e., it's near impossible, especially at number of dices thrown above 3, to get numbers somewhat low or high - which is normal, but only to an extent).

    2) Array formulas seem to be the solution to what I needed. But it didn't work on my excel sheet, saying I had insufficient number of arguments. I will go back to work on it at a later time: probably I missed something, but I will have to check my translation (cause I have to work with an Office in french) too.

    Thanks for the help you have given me, I couldn't find any answer anywhere else on the web.
    Attached Files Attached Files

  18. #18
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Multiple dice roller (d6) with two cells and one formula?

    I tested both solutions against the actual statistical distribution for 3 dice rolls and am comfortable they give the right distribution

  19. #19
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Multiple dice roller (d6) with two cells and one formula?

    It occurs to me you only need one array, so:

    =SUM(RANDBETWEEN(IF(1,ROW(INDIRECT("1:"&A2))/ROW(INDIRECT("1:"&A2))),6))

  20. #20
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Multiple dice roller (d6) with two cells and one formula?

    Stomper, that is a leap of insight. Very nice.

  21. #21
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Multiple dice roller (d6) with two cells and one formula?

    Just to generalize for N-sided dice, starting with any number,

    Row\Col
    A
    B
    C
    1
    iMin
    1
    2
    sides, N
    6
    3
    dice, M
    10
    4
    roll
    43
    B4: {=SUM(RANDBETWEEN(ROW(INDIRECT("1:" & M)) ^ 0, N)) + M * (iMin-1)}
    Last edited by shg; 10-19-2014 at 03:39 PM.

  22. #22
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: Multiple dice roller (d6) with two cells and one formula?

    Er, couldn't this be done with just

    =RANDBETWEEN(B3,B2*B3)

    Where Sides on a dice is B2 and # of dice is B3?

    or am i missing something
    You should hit F5, because chances are I've edited this post at least 5 times.
    Example of Array Formulas
    Quote Originally Posted by Jacc View Post
    Sorry, your description makes no sense. I just made some formula that looks interesting cause I had nothing else to do.
    Click the * below on any post that helped you.

  23. #23
    Valued Forum Contributor
    Join Date
    04-22-2014
    Location
    Auckland, New Zealand
    MS-Off Ver
    Office 365 (work) and Excel 2013 (home)
    Posts
    1,167

    Re: Multiple dice roller (d6) with two cells and one formula?

    Quote Originally Posted by Speshul View Post
    Er, couldn't this be done with just

    =RANDBETWEEN(B3,B2*B3)

    Where Sides on a dice is B2 and # of dice is B3?

    or am i missing something
    Yes you are missing something. Each dice (6 sided) will average 3.5 so as the number of dice/rolls increases the likely hood is that the total will be approximately 3.5 times the total number of rolls, and outliers at the top and bottom end of the possible totals will be less likely. =RANDBETWEEN(B3,B2*B3) means that all outcomes in the range are equally likely, so therefore not a real world facsimile.
    Please add reputation by clicking on the * if I have helped.
    Please mark the thread SOLVED if your issue has been resolved.
    Thanks, Glenn.

  24. #24
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Multiple dice roller (d6) with two cells and one formula?

    Like GAk67 said, your formula will give equal probability for all numbers between lower and upper where as the multple dice roll will have a bell shaped distribution with very low probability at teh extremes. ie hte probability of getting a sum of 3 ina three dice roll is 1 in 216 yet with your formula the probability of a 3 is 1 in 18

  25. #25
    Valued Forum Contributor
    Join Date
    04-22-2014
    Location
    Auckland, New Zealand
    MS-Off Ver
    Office 365 (work) and Excel 2013 (home)
    Posts
    1,167

    Re: Multiple dice roller (d6) with two cells and one formula?

    To elaborate on romperstomper's formula I would go with this array formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Where A2 = number if dice, B2 = number of times those dice are rolled, and C2 = the number of sides each dice has.

  26. #26
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Multiple dice roller (d6) with two cells and one formula?

    Post #21 ?

+ 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. Automatic Dice Roller
    By whitfpj in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-15-2014, 01:58 AM
  2. Dice Possible Outcomes Macro / Formula?
    By duguerre in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-13-2013, 01:10 PM
  3. Excel Dice Game
    By Jay_hl in forum Excel General
    Replies: 7
    Last Post: 07-02-2012, 09:40 AM
  4. Roller del mouse su editor VBA
    By Wallace in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-29-2005, 03:05 PM
  5. [SOLVED] programming a dice roll
    By Carl in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-19-2005, 11:05 PM

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