2

I'm trying to generate random numbers in an interval, x number of times. Imagine rpg dice sintax, like: 3d6 means roll 3 times a dice of 6 sides. Or 5d100 means roll 5 dices of 100 sides. If I was to generate one x-sided dice y times, how can I do this?.

Image of dice selector

In this case, on B4, I used:

IF(B3 = TRUE;RANDBETWEEN(1;4))

But this only generate one d4. I want to generate b2 number of d4's, but don't know how. Can someone help me?

0

3 Answers 3

1

Basic Formula

=IF(C4*$K$2, BYROW(SEQUENCE(C3),
    LAMBDA(roll, RANDBETWEEN(1, C2))),)
  • formula needs to be pasted into each cell of the range B5:I5

;

Advanced Single Formula

  • Formula is placed only in B5 and fills in all the other columns.
=BYCOL(B2:I4, LAMBDA(col, IF(INDEX(col,3)*K2, 
   BYROW(SEQUENCE(INDEX(col,2)), LAMBDA(roll, 
     RANDBETWEEN(1, INDEX(col, 1)))),)))

;

Roll Count Formula [optional]

  • This formula in A5 adds as many "Roll #" entries as needed based on the maximum number of rolls in the current results.
=BYROW(B5:I, LAMBDA(r, IF(SUM(r),
  "Roll "& ROW(r)+1-ROW(), IFNA(#N/A)))) 

0

Try this formula:

=IF(B3 = TRUE,RANDBETWEEN((1*B2),(B1*B2)),)

Logic

  • If checkbox is ticked - calculate dice roll

  • If check box is not ticked, cell is blank

  • Dice Roll

    • use RANDBETWEEN(low, high)
    • low = 1 multiplied by the number of dice rolls
    • high = number of sides multiplied by the number of dice rolls

RESULT

snapshot

0

You need one RANDBETWEEN for every throw, so I would do it like this (here without the checkbox):

=RANDBETWEEN(1;B1)+IF(B2>1;RANDBETWEEN(1;B1))+IF(B2>2;RANDBETWEEN(1;B1))+IF(B2>3;RANDBETWEEN(1;B1))+...

Add as many IFs as needed to handle the max number of throws.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.