While working with Excel, we are able to generate random numbers by using the RANDBETWEEN function. However, if we have a given set of values to choose from, we can combine the **CHOOSE **and **RANDBETWEEN **functions. This step by step tutorial will assist all levels of Excel users in generating random numbers from a fixed set of options.

*Figure 1. Final result: Random number from fixed set of options*

Final formula: **=CHOOSE(RANDBETWEEN(1,4),0,2,4,6)**

**Syntax of CHOOSE Function**

CHOOSE function returns a value from a list of values based on the index_num provided

**=CHOOSE(index_num, value1, [value2], ...)**

**index_num**– determines which value in the list of values is returned by the CHOOSE function- Index_num must be a number between 1 and 254, or a cell reference with values between 1 and 254
- Value1 is returned if index_num is 1, values2 if index_num is 2; and so on
- CHOOSE returns the error #VALUE! if index_num is less than 1 or greater than the number of the last value in the list

**value1, value2, …**Only value 1 is required, succeeding values are optional; The arguments can be numbers, cell references, defined names, formulas, functions, or text.

**Syntax of RANDBETWEEN Function**

RANDBETWEEN randomly returns an integer between the numbers we specify

**=RANDBETWEEN(bottom, top)**

**bottom**– the smallest integer that RANDBETWEEN will randomly return**top**– the largest integer that RANDBETWEEN will randomly return

**Setting up Our Data**

Here we have a 4×4 table which we will randomly populate with the numbers 0, 2, 4 and 6.

* Figure 2. Sample data for random number from fixed set of options*

**Generate random number**

We want to fill cells B3:E6 with the numbers 0, 2, 4 and 6. We can do this by using the CHOOSE and RANDBETWEEN functions. Here are the steps:

**Step 1**. Select cell B3

**Step 2**. Enter the formula: `=CHOOSE(RANDBETWEEN(1,4),0,2,4,6)`

**Step 3**: Press ENTER

**Step 4**: Copy the formula in cell B3 to cells B3:E6 by clicking the “+” icon at the bottom-right corner of cell B3 and dragging it down to B6, then right towards E6.

* Figure 3. Entering the formula using CHOOSE and RANDBETWEEN*

Our formula chooses a number from a fixed set of options: 0, 2, 4 and 6. There are four options, so the index_num for our CHOOSE function should be an integer between 1 and 4. The index_num is determined by the function: **RANDBETWEEN**(**1,4**). The RANDBETWEEN generates random integers from 1 to 4, which in turn determines which number CHOOSE returns.

For index_num 1, CHOOSE will return the value “**0**”; for index_num 2, it will return “**2**”; for index_num 3, it will return “**4**”; and for index_num 4, it will return “**6**”.

Below table shows our 4×4 table already filled randomly with numbers 0, 2, 4 and 6.

* Figure 4. Output: Random number from fixed set of options*

Note: The random integer number returned by RANDBETWEEN changes every time the worksheet is changed. We can fix the values to prevent further changes by following these steps:

**Step 1**. Select cells B3:E6

**Step 2**. Press **Ctrl + C** to copy the values

**Step 3**: Right click then choose “**Values (V)**” under the “**Paste Options**”

**Step 4**: Press Enter

This will change the formulas into values and prevent any further random changes.

Most of the time, the problem you will need to solve will be more complex than a simple application of a formula or function. If you want to save hours of research and frustration, try our live Excelchat service! Our Excel Experts are available 24/7 to answer any Excel question you may have. We guarantee a connection within 30 seconds and a customized solution within 20 minutes.

## Leave a Comment

Please give show me the formula and steps to generate five numbers out of ninety.

Comment awaiting moderation