You can use the **RANDBETWEEN** function in Excel to generate a random integer between two specific numbers.

However, if you’d like to generate a random value *with decimals* between two specific numbers, then you can use the following syntax:

=RANDBETWEEN(20*1000,50*1000)/1000

This particular formula will generate a random number with three decimal places between **20** and **50**.

The following example shows how to use this formula in practice.

**Example: Use RANDBETWEEN Function with Decimals in Excel**

Suppose we would like to generate a random integer between 20 and 50.

We can type the following formula into cell **A1** to do so:

=RANDBETWEEN(20, 50)

The following screenshot shows how to use this formula in practice:

The formula returns a value of **27**.

Notice that this number is an integer and does not include any decimal places.

Suppose instead we’d like to generate a random number *with three decimals* between 20 and 50.

We can type the following formula into cell **A1** to do so:

=RANDBETWEEN(20*1000,50*1000)/1000

The following screenshot shows how to use this formula in practice:

The formula returns a value of **27.991**.

Notice that this value includes three decimal places since we multiplied both the lower and upper value in the **RANDBETWEEN** function by 1,000 and then divided the final result by 1,000.

If we would instead like to include only two decimal places, we could use **100** instead of **1,000** in the formula.

For example, we could instead type the following formula into cell **A1**:

=RANDBETWEEN(20*100,50*100)/100

The following screenshot shows how to use this formula in practice:

The formula returns a value of **27.83**.

Notice that this value includes two decimal places since we multiplied both the lower and upper value in the **RANDBETWEEN** function by 100 and then divided the final result by 100.

**Additional Resources**

The following tutorials explain how to perform other common operations in Excel:

How to Randomly Select Cells Based on Criteria in Excel

How to Select a Random Sample in Excel

How to Generate Random Dates in Excel