excel use randbetween function with decimals

Excel: Use RANDBETWEEN Function with Decimals


The Excel environment provides a robust suite of functions for mathematical and statistical analysis, including powerful tools for random number generation. Specifically, the RANDBETWEEN function is a highly utilized tool designed to return a random whole number, or integer, situated between two specified numerical boundaries (the bottom and top limits). This function is essential for simulations, statistical sampling, and creating randomized data sets where only whole numbers are acceptable outcomes.

While the standard use of the RANDBETWEEN function is straightforward for generating integers, a common requirement in advanced data modeling involves generating random numbers that include decimal places. Directly applying `RANDBETWEEN` cannot achieve this, as its definition strictly mandates integer output. To bypass this inherent limitation and generate a random value with decimals between two defined constraints, we must employ a mathematical scaling technique involving multiplication and subsequent division.

The core technique involves transforming the desired decimal range into an integer range by multiplying the minimum and maximum boundaries by a power of 10. This scaling factor determines the desired precision, or the number of decimal places we wish to maintain. Once the scaled `RANDBETWEEN` calculation is performed, the resulting large integer is then divided by the same scaling factor. This sophisticated method ensures that the output is a random number within the original range but now includes the necessary fractional component, thereby satisfying the requirement for decimal precision. For instance, to generate numbers between 20 and 50 with three decimal places, the following scaling syntax is utilized:

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

This formula effectively generates a random integer between 20,000 and 50,000, and then divides it by 1,000, yielding a precise random number between 20 and 50 with up to three decimal places of accuracy. The subsequent sections will detail practical examples demonstrating the implementation and results of this specialized formula structure in Excel.

Understanding the Default: Generating Integers

Before implementing the decimal scaling solution, it is beneficial to review the standard application of the RANDBETWEEN function to establish a performance baseline. This function requires two arguments: the bottom limit and the top limit. When generating random numbers, it is crucial to understand that both the bottom and top limits are inclusive, meaning the generated number can be equal to either boundary.

Suppose, for statistical modeling or simple data population, we are tasked with generating a random integer between the values of 20 and 50. The standard, unscaled formula typed into a target cell, such as A1, would be straightforward:

=RANDBETWEEN(20, 50)

This formula instructs Excel to select a random whole number from the finite set of integers spanning 20, 21, 22, …, up to 50. This function is categorized as volatile, meaning it recalculates every time the spreadsheet changes or is opened, generating a new random output value.

The following illustration provides a visual confirmation of the result when using the base `RANDBETWEEN` implementation. Notice that the resulting output strictly adheres to the definition of the function by providing an integer output, devoid of any fractional component.

As demonstrated in the visual example, the formula returns a value of 27. This outcome is an integer, successfully falling within the defined range of 20 to 50, and notably does not include any decimal places. This confirms the inherent limitation that necessitates the scaling technique when decimal precision is required.

The Scaling Solution for Three Decimal Places

When the requirement shifts from simple integers to precise random numbers incorporating decimal places—for instance, generating values between 20 and 50 accurate to three decimal points—we must utilize the scaling methodology. The crucial step is determining the appropriate scaling factor. Since we require three decimal places of precision, we use 10 raised to the power of three, which is 1,000. This factor transforms the range from [20, 50] to [20,000, 50,000], thereby ensuring that `RANDBETWEEN` operates on a sufficiently large set of integers that can be scaled down accurately.

To implement this advanced calculation, we incorporate the scaling factor into the `RANDBETWEEN` arguments and then divide the entire result by the same factor. We would type the following formula into the designated cell, such as A1:

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

Detailed analysis of this structure reveals its mechanism: First, the formula calculates the minimum and maximum scaled integers (20,000 and 50,000). Second, the RANDBETWEEN function selects a random integer from this magnified range. Finally, dividing this large random number by 1,000 effectively moves the decimal point three places to the left, restoring the number to the original range [20, 50] while preserving the three digits of randomness generated by the internal integer selection.

The subsequent screenshot illustrates the practical application of this scaling formula and the resulting output. This outcome confirms the successful generation of a precise random number that fulfills the decimal requirement.

In this execution, the formula returns a value of 27.991. This outcome clearly demonstrates that the value successfully includes three decimal places. This success is directly attributable to the deliberate use of the scaling factor of 1,000, which was applied both by multiplying the lower and upper bounds within the RANDBETWEEN function and by dividing the final result, ensuring the generated randomness corresponds precisely to the required fractional components.

Controlling Precision: Adjusting the Scaling Factor

The method’s power lies in its flexibility regarding the required precision. The scaling factor (the power of 10) is the sole determinant of how many decimal places the generated number will contain. If three decimal places necessitate using 1,000 (10^3), then requiring fewer or more decimal places simply means adjusting this factor accordingly.

For scenarios demanding only two decimal places of accuracy, the appropriate scaling factor becomes 100 (10^2). Using 100 transforms the range [20, 50] into the scaled integer range [2,000, 5,000]. This scaled range ensures that the RANDBETWEEN function selects an integer that, when divided by 100, yields exactly two digits following the decimal point.

Similarly, for high-precision modeling, such as financial or scientific computations that might require five decimal places, the scaling factor would be 100,000 (10^5). It is important to confirm that the chosen scale factor results in an integer range that does not exceed Excel’s maximum computational limits, though typical decimal requirements rarely approach such extremes that this becomes a practical constraint.

The relationship between the scaling factor and the decimal count is direct and predictable. We can summarize this relationship for easier reference:

  • For one decimal place, use a scaling factor of 10.
  • For two decimal places, use a scaling factor of 100.
  • For three decimal places, use a scaling factor of 1,000.
  • For ‘n’ decimal places, use a scaling factor of 10 raised to the power of ‘n’.

This systematic approach allows content creators and analysts to generate random data sets with controlled and consistent precision across various applications, moving beyond the fixed integer output of the default RANDBETWEEN function.

Example 3: Generating Decimals with Two Places

To illustrate the application of a lower scaling factor, let us adapt the previous example to generate a random number between 20 and 50, but this time requiring only two decimal places. Following the scaling principle, we will replace the factor of 1,000 with 100 throughout the formula. We can input the following revised formula into cell A1:

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

Execution of this formula first generates a random integer between 2,000 and 5,000. Subsequently, dividing the result by 100 yields a random number within the desired original range of [20, 50], now accurately displaying two fractional digits. This precise control over the output format makes the scaled RANDBETWEEN function highly versatile for modeling scenarios where granular control over precision is essential.

The screenshot below displays the outcome of utilizing the scaling factor of 100. Note the confirmation that the generated number remains within the specified boundaries while providing the two required decimal digits.

Upon calculation, the formula returns a value of 27.83. This result confirms that the value now includes exactly two decimal places, which is the precise outcome targeted by using the scaling factor of 100. This example solidifies the principle that the selected factor directly dictates the precision of the generated random number, offering complete control over the fractional component of the output.

Alternative Method: Utilizing the RAND Function for Decimals

While scaling RANDBETWEEN is an effective solution, an alternative and often cleaner method for generating random numbers with decimals in Excel involves using the fundamental RAND function. The `RAND` function inherently generates a random floating-point number that is greater than or equal to 0 and less than 1 (i.e., in the interval [0, 1)). This function, by its nature, produces decimals, making it suitable for direct manipulation into a custom range.

To generate a random number ‘R’ between a low boundary ‘A’ and a high boundary ‘B’ using `RAND`, the general formula structure is: R = A + (B – A) * RAND(). Here, (B – A) calculates the size of the interval, and multiplying it by `RAND()` selects a random fraction of that interval size. Adding ‘A’ then shifts this result into the correct starting range.

For our specific range (A=20, B=50), the formula would be:

=20 + (50 - 20) * RAND()

or simplified:

=20 + 30 * RAND()

This method automatically generates a random number with high precision (many decimal places) between 20 and 50. If you require a specific number of decimal places (e.g., three), you would wrap the entire formula in the ROUND function, such as `ROUND(20 + 30 * RAND(), 3)`. This offers superior clarity compared to the multiplication and division required by the RANDBETWEEN function scaling method, although both achieve valid random number generation.

Volatility and Static Random Number Generation

A crucial consideration when working with both RANDBETWEEN and RAND function is their classification as volatile functions. This means that every time a change is made to any cell in the worksheet, or when the workbook is opened or saved, these functions automatically recalculate, generating a completely new set of random numbers. While this behavior is suitable for live simulations, it is often detrimental when static, reproducible random data sets are required for analysis or documentation.

If the goal is to generate a fixed set of random numbers, the volatility of the function must be countered by converting the formula results into static values. This procedure is typically accomplished by utilizing the “Paste Special” feature. After generating the desired random numbers using the scaled formula (e.g., in column A), the user must select the range, copy it, and then use Paste Special to paste only the Values back into the same location. This action replaces the volatile formula with the calculated numerical output.

The steps for creating static random values are standardized:

  1. Input the scaled formula (e.g., =RANDBETWEEN(20*1000,50*1000)/1000) into the starting cell and drag it down across the required range.
  2. Select the entire range containing the calculated random values.
  3. Copy the selected range (Ctrl+C or Command+C).
  4. Right-click the selected range, choose Paste Special, and select Values (or use the appropriate keyboard shortcut for pasting values).

Once the values are pasted, the random numbers are permanently fixed, ensuring that subsequent changes to the workbook will not trigger the recalculation and alteration of the critical data set. This step is indispensable for maintaining data integrity in statistical and analytical reports based on random number generation.

Summary of Decimal Precision Control

Generating random numbers with controlled decimal places in Excel using the RANDBETWEEN function requires a calculated mathematical workaround based on scaling. By multiplying both the lower and upper bounds by a factor of 10^n (where ‘n’ is the required number of decimal places) and then dividing the final result by the same factor, we successfully transform the integer-only output into a highly precise random fractional number.

The three primary formulas demonstrated cover the most common use cases:

  • For Integers: =RANDBETWEEN(Bottom, Top)
  • For Three Decimals: =RANDBETWEEN(Bottom*1000, Top*1000)/1000
  • For Two Decimals: =RANDBETWEEN(Bottom*100, Top*100)/100

While the alternative use of the RAND function combined with ROUND offers a conceptually simpler method for generating decimals, mastering the scaling technique for RANDBETWEEN function provides essential insight into manipulating integer-based functions to achieve fractional results. Regardless of the function chosen, users must always remember the volatile nature of these tools and convert the results to static values if the generated data needs to be preserved.

Cite this article

stats writer (2025). Excel: Use RANDBETWEEN Function with Decimals. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/excel-use-randbetween-function-with-decimals/

stats writer. "Excel: Use RANDBETWEEN Function with Decimals." PSYCHOLOGICAL SCALES, 17 Nov. 2025, https://scales.arabpsychology.com/stats/excel-use-randbetween-function-with-decimals/.

stats writer. "Excel: Use RANDBETWEEN Function with Decimals." PSYCHOLOGICAL SCALES, 2025. https://scales.arabpsychology.com/stats/excel-use-randbetween-function-with-decimals/.

stats writer (2025) 'Excel: Use RANDBETWEEN Function with Decimals', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/excel-use-randbetween-function-with-decimals/.

[1] stats writer, "Excel: Use RANDBETWEEN Function with Decimals," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, November, 2025.

stats writer. Excel: Use RANDBETWEEN Function with Decimals. PSYCHOLOGICAL SCALES. 2025;vol(issue):pages.

Download Post (.PDF)
Slide Up
x
PDF
Scroll to Top