

1 are "caught" by the lookup table and return a position of 1. As mentioned above, the first value in D5:D10 is deliberately zero to ensure that values below. When MATCH encounters a value larger than the largest last value in D5:D10 (.7 in the example), it returns the last position (6 in the example). In practical terms, this means the MATCH function travels along the values in D5:D10 until a larger value is encountered, then "steps back" to the previous position. When match type is omitted, MATCH will return the position of the largest value less than or equal to the lookup value*. The third argument for MATCH, match type, is omitted. The lookup array is the range D5:D10, locked so it won't change as the formula is copied down the column.

RAND generates a random value between zero and 1. Inside MATCH, the lookup value is provided by the RAND function. To generate a random value, using the weighted probability in the helper table, F5 contains this formula, copied down: =MATCH(RAND(),D$5:D$10) This is to make sure MATCH is able to find a position for all values down to zero as explained below.

Notice, we are intentionally shifting the cumulative probability down one row, so that the value in D5 is zero. Column D contains the cumulative probability, created with this formula in D5, copied down: =SUM(D4,C4) Column C contains the probability weight assigned to each number, entered as a percentage. Column B contains the six numbers we want as a final result. This formula relies on the helper table visible in the range B4:D10.
