Excel Tip: Find Random Integer Within a Selected Range

Excel's random number generating function, RAND, normally produces a random number that is a five- or six-digit decimal greater than or equal to 0 and less than 1. The function appears in your spreadsheet like this:

=RAND()

With a little customization, you can tailor this function to provide integers instead of decimals, and you can request the range within which the results should fall.

For example, if you want to find a random number between 1 and 500,000, the formula would look like this:

=INT(RAND()*(500000-1)+1)

A random number between 100 and 1,000 would be generated with this function:

=INT(RAND()*(1000-100)+100)

To find additional random numbers within the specified range, press the F9 function key and the random number function will recalculate.

Note that each time you recalculate or re-open a worksheet containing the random number function, the function will recalculate. Should you want to retain a random number that was generated with this function, enter the number without the function in a separate cell.

Excel Add-In

If you have installed Excel's Analysis ToolPak, there is a function in the ToolPak that performs this procedure. It is the RANDBETWEEN function, and you would use it like this:

=RANDBETWEEN(1,500000)

The Analysis ToolPak can be installed by selecting Add-Ins on the Tools menu, then requesting the ToolPak. You will need your installation CD to install this feature.

Voice of the Editor

What would you do if one of your clients won the lottery? We asked several accountants to weigh in with their advice for the lucky Powerball winner, and the tips we received are useful for anyone who receives a windfall, whether it's a lottery win, an inheritance, a big bonus on the job, or a killing in the stock market.
ADVERTISEMENT

This Week on AccountingWEB

CPAs Mira Finé, Scott Hitchcock, Rob Keasal, Kathy Scorcio, and Ken Travis offer ten pieces of financial advice for the newest Powerball winner.
Hang Bower of BDO USA and Dan Black of Ernst & Young share their perspectives on why their firms made the Best Places to Work for Recent Grads 2013 list.
Herbein + Company, Inc. firm members talked with AccountingWEB about their year-round employee wellness program.
Bill Walter of Gross, Mendelsohn & Associates and Harold Gaar of TravisWolff LLP weigh in on mobile technology use while employees are at work.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT