Movatterモバイル変換


[0]ホーム

URL:


How-To Geek logo

How to Generate Random Numbers in Microsoft Excel

Microsoft Excel logo on a green background
4
By Sandy Writtenhouse
Sign in to yourHow-To Geek account
Jump links

Jump Links

follow
Follow
followed
Followed
Here is a fact-based summary of the story contents:
Try something different:

If you need to generate one or more random numbers for business, education, or another purpose, you can do so right in Microsoft Excel. You canget random numbers using either a random number generator tool or an Excel function.

Related:How to Generate Random Numbers in Google Sheets

Use the Random Number Generator in Excel

With an add-in from Microsoft calledAnalysis ToolPak, you can perform many statistical and engineering operations such asfinding a moving average. Another feature of the tool is a random number generator.

Add the Analysis ToolPak

To see if you already have the add-in, go to the Data tab and the Analysis section of the ribbon. Look for the Data Analysis button. If you have the button, you can skip down to using the tool.

Go to Data, Data Analysis

If you don't see the button, you can add it easily. Go to File > Options and select "Add-ins" on the left. At the bottom of the window, go to Manage and pick "Excel Add-ins." Click "Go."

Select Add-ins, Manage Excel Add-ins

When the Add-ins window opens, check the box next to Analysis ToolPak and click "OK."

Add the Analysis ToolPak

Use the Random Number Generator

Head to the Data tab and click "Data Analysis" in the Analysis section of the ribbon. When the window appears, select "Random Number Generation" and click "OK."

Select Random Number Generation

Starting at the top of the window, enter the number of columns you want to fill using the Number of Variables box. Then, enter the number of rows in the Number of Random Numbers box.

Add the number of columns and rows

This generator is advanced in that you can select the distribution you want to use from options like Bernoulli, Binomial, Patterned, and Discrete. Once you select the Distribution from the drop-down list, the Parameters section will update with the necessary information for you to complete.

Pick a Distribution

In the Random Seed field, you can enter a starting number (up to 9999) for the generator to use if you like. Then, choose one of the Output Options for where you want your random numbers to display.

Add a Seed and pick the Output

Click "OK" when you're ready and you'll receive your numbers.

Random numbers generated

Use the Random Number Functions in Excel

Another option for generating random numbers in Excel is using a function. There are threefunctions you can use. Each time you recalculate or reopen the workbook, a new random number will be generated with these functions. They don't offer as many options as the Random Number Generator tool, but they're simpler to use.

Related:How to Find the Function You Need in Microsoft Excel

The RAND Function

With the

RAND

function, you can generate a random number greater than or equal to zero and less than one. This provides you with decimal number options. But you can also get numbers going higher than one by tweaking the formula.

For a basic random number, enter the following and press Enter:

=RAND()

RAND function in Excel

For a random number greater than or equal to zero and less than 500, enter the following and hit Enter:

=RAND()*500

RAND function for less than 500

For a random whole number greater than or equal to zero and less than 500, enter the following and press Enter:

=INT(RAND()*500)

Whole number less than 500

The RANDBETWEEN Function

Maybe you want to generate a number that's between two specific numbers. In this case, you'd use theRANDBETWEEN  function.

For a random number between 10 and 100, enter the following and press Enter:

=RANDBETWEEN(10,100)

RANDBETWEEN positive numbers

For a random number between negative 10 and 10, enter the following and hit Enter:

=RANDBETWEEN(-10,10)

RANDBETWEEN with negative number

Related:How to Create Random (Fake) Datasets in Microsoft Excel

The RANDARRAY Function

ForMicrosoft 365 subscribers, theRANDARRAY function provides a set of random numbers. You can choose the number of rows and columns to fill with numbers. You can also select minimum and maximum values and specify whole numbers or decimals.

The syntax for this function isRANDARRAY(rows, columns, minimum, maximum, whole-decimal) where you enterTrue for a whole number orFalse for a decimal number as the last argument. All arguments are optional.

For a random array of numbers that cover three rows and four columns, you'd enter the following and hit Enter:

=RANDARRAY(3,4)

RANDARRAY with rows and columns

For a random array that covers the same number of rows and columns but also has a minimum of 1 and a maximum of 10, enter the following and press Enter:

=RANDARRAY(3,4,1,10)

RANDARRAY with minimum and maximum values

For a random array using these same arguments but returns only whole numbers, you would enter the following and press Enter:

=RANDARRAY(3,4,1,10,TRUE)

RANDARRAY with whole numbers

Microsoft Excel gives you easy options forgenerating random numbers. Whether you need a discrete number or simply a number between one and 10, Excel has you covered.

Mastering Excel Functions

Functions

AVERAGE · CONCATENATE · COUNT · COUNTIF · DATEDIF ·FILTER ·FREQUENCY · FV · HYPERLINK · IF · IFS · IMAGE · INDEX · IS · LEN · MATCH ·MEDIAN · RAND · ROUND· RRI · SORT · SQRT · SUBSTITUTE · SUBTOTAL ·SUM · SUMIF · TODAY · TRIM · TRUNC · VLOOKUP · WEEKDAY · XLOOKUP· YEAR

Types

Basic · Budgeting· Data Entry· Logical · Text · Time and Date

Explained

Copying Formulas· Evaluating Formulas· Finding Functions · Fixing Formula Errors· Functions vs Formulas · Comparing Lookup Functions· Locking Formulas · Structuring Formulas · Translating Formulas

Follow
Followed
Share
FacebookXWhatsAppThreadsBlueskyLinkedInRedditFlipboardCopy linkEmail
Readers like you help support How-To Geek. When you make a purchase using links on our site, we may earn an affiliate commission.Read More.
Illustration of a blue calculator with the letters D-U-M-B on its buttons, framed on both sides by large curly brackets.
Why I keep starting weird projects I don’t actually need
A relaxed man lounging on an orange beanbag watches as a friendly yellow robot works on a laptop for him, while multiple red exclamation-mark warning icons float around them.
3 reasons why vibe coding is a terrible idea
A MacBook surrounded by a gear symbol, a shield, an iCloud icon, and a password dots bar.
I made my Mac more secure by changing these 5 settings
See More
The back of the OnePlus 15 sitting in grass and leaves.
The OnePlus 15 can finally be sold in the U.S.
A replacement battery for a Kindle third generation eReader.
It’s time to admit you can swap out internal rechargeable batteries yourself
Several smartphones arranged diagonally on a blue geometric background, each displaying a simple home screen with a solid black wallpaper
Black is the new best wallpaper for your phone
See More

[8]ページ先頭

©2009-2025 Movatter.jp