HomeHow To Use The RANDBETWEEN Function In Google SheetsFormulas & FunctionsHow To Use The RANDBETWEEN Function In Google Sheets

How To Use The RANDBETWEEN Function In Google Sheets

The RANDBETWEEN function is an incredibly practical tool designed to generate a random integer (a whole number) between two designated endpoints.

For instance, if you type =RANDBETWEEN(1,10) into your spreadsheet, the software will automatically generate a random number ranging from 1 to 10. Keep in mind that this figure will actively recalculate and generate a new random value every time a change is made to your worksheet.

For example, this RANDBETWEEN formula generates a random number between 1 and 10:

=RANDBETWEEN(1,10)

RANDBETWEEN Function In Google Sheets

The function will generate a new random number each time your Sheet changes.

RANDBETWEEN Function Examples

You can easily adapt this formula to suit a variety of numerical scenarios:

  • To generate a standard random figure between 1 and 1000, simply input =RANDBETWEEN(1,1000).
  • If you want to pull your upper and lower boundaries directly from other cells, you can reference them. If your LOW target is in cell A1 and your HIGH target is in cell A2, type =RANDBETWEEN(A1,A2).
  • The function also perfectly handles negative numbers. To pull a random value between -100 and -1, use =RANDBETWEEN(-100,-1).
  • To span across both negative and positive integers, a formula like =RANDBETWEEN(-999,999) works seamlessly.

RANDBETWEEN Function Syntax

=RANDBETWEEN(low, high)

It takes two arguments:

low

An integer (whole number) that represents the lower bound of your random number set.

high

An integer (whole number) that represents the upper bound of your random number set.

RANDBETWEEN Notes

Understanding how this tool behaves behind the scenes is vital for maintaining spreadsheet performance. RANDBETWEEN operates as a volatile function, which means it triggers a complete recalculation every time you edit a cell or open the document.

You can manually force these recalculations to happen on a timed schedule (such as every minute or every hour) by navigating to the File menu, clicking Settings, selecting Calculation, and adjusting the Recalculation dropdown menu. However, if your document contains hundreds of these formulas—or downstream cells referencing them—it can cause significant lag because the software is constantly forced to update every connected figure.

Additionally, if you input decimal numbers instead of whole integers, the formula forces rounding. The LOW boundary will always round up, and the HIGH boundary will always round down. For example, =RANDBETWEEN(2.5,3.5) will constantly output 3. This happens because the lower bound of 2.5 rounds up to the integer 3, and the upper bound of 3.5 rounds down to the integer 3.

Google Sheet Calculation Settings

If you have a lot of RANDBETWEEN functions in your Sheet (or a lot of downstream formulas that reference a RANDBETWEEN function), this can lead to slow Google Sheets because it will keep recalculating all those formulas with every change.

If decimal numbers are used as input values, the LOW value will be rounded up for the lower boundary and the HIGH value will be rounded down for the upper boundary.

For example:

=RANDBETWEEN(2.5,3.5)

will always output 3 because the LOW value of 2.5 equates to an integer of 3 as the lower random number bound, and the HIGH value of 3.5 equates to an integer of 3 too, as the upper random number bound.

To generate a random decimal number, use the RAND Function.

To generate an array of random numbers, use the RANDARRAY Function.

How To Select A Random Item From A Column Using RANDBETWEEN

Suppose we have data in column A and we want to select a random item from this list.

Use this formula, which combines the RANDBETWEEN function, the COUNTA function, and the INDEX function, to return a random item:

=INDEX(A2:A21,RANDBETWEEN(1,COUNTA(A2:A21)))

Random Item From List

Suppose you have a list of names or products in column A, and you want the software to pick one item at random. You can combine RANDBETWEEN with the COUNTA and INDEX functions to achieve this:

=INDEX(A2:A21, RANDBETWEEN(1, COUNTA(A2:A21)))

Using the “onion framework” to peel back the layers from the inside out helps explain how this works:

  1. =COUNTA(A2:A21) counts the exact number of populated values within that specific column.
  2. =RANDBETWEEN(1, COUNTA(A2:A21)) generates a random number between 1 and the total count of those items.
  3. Finally, the INDEX function performs standard data indexing, returning the text item from the exact row position matching that randomly generated number.

RANDBETWEEN And CHOOSE Function

Combine the RANDBETWEEN function and the CHOOSE function to pick random items from a list:

=CHOOSE(RANDBETWEEN(1,5),"Person 1","Person 2","Person 3","Person 4","Person 5")

The values can also be referenced in cells, as in this example:

=CHOOSE(RANDBETWEEN(1,5),A1,A2,A3,A4,A5)

Randbetween And Choose Function in Google Sheets

RANDBETWEEN Function Template

When practicing these concepts, it is highly recommended to use a view-only template. You can seamlessly copy a template into your own workspace by navigating to File > Make a copy. If your organization’s Workspace settings block access, simply copying the link into an Incognito window usually bypasses the restriction. This tool is a proud member of the Math family of functions, and deeper technical insights can be found in the official documentation.

Leave a Reply

Your email address will not be published. Required fields are marked *