Excel RANDARRAY Function: Complete Guide to Generating Random Numbers (2025)

Published: December 17, 2024 - 3 min read

Julian Alvarado

The RANDARRAY function in Excel provides a powerful way to generate arrays of random numbers directly in your spreadsheet. Whether you need to create sample data, simulate scenarios, or perform statistical analysis, RANDARRAY offers a flexible solution for generating random values efficiently.

How to Generate Random Numbers Using RANDARRAY in Excel

The RANDARRAY function uses a straightforward syntax to create arrays of random numbers:

Copy

=RANDARRAY(rows, columns, min, max, whole_number)

Let’s break down each parameter:

  • rows (optional): Number of rows in the output array
  • columns (optional): Number of columns in the output array
  • min (optional): Minimum value (default is 0)
  • max (optional): Maximum value (default is 1)
  • whole_number (optional): TRUE for integers, FALSE for decimals (default is FALSE)

Basic Examples:

  1. Generate a 3×3 array of random decimals between 0 and 1:

Copy

=RANDARRAY(3,3)

Example output:

 

A

B

C

1

0.66

0.75

0.62

2

0.78

0.34

0.10

3

0.32

0.61

0.17

  1. Create a 2×4 array of random whole numbers between 1 and 100:

Copy

=RANDARRAY(2,4,1,100,TRUE)

Example output:

 

A

B

C

D

1

57.00

72.00

99.00

17

2

24.00

62.00

45.00

83

Creating Arrays with Whole Numbers vs Decimals

The whole_number parameter determines whether your output contains integers or decimal numbers.

For decimals:

Copy

=RANDARRAY(2,2,1,10,FALSE)

Example output:

 

A

B

1

3.85

7.92

2

9.04

5.42

For whole numbers:

Copy

=RANDARRAY(2,2,1,10,TRUE)

Example output:

 

A

B

1

Coefficient Excel Google Sheets Connectors
Try the Free Spreadsheet Extension Over 500,000 Pros Are Raving About

Stop exporting data manually. Sync data from your business systems into Google Sheets or Excel with Coefficient and set it on a refresh schedule.

Get Started

1

6

2

10

7

Specifying Custom Array Sizes

You can create arrays of any size by adjusting the rows and columns parameters:

Single column (vertical array):

Copy

=RANDARRAY(5,1,1,100,TRUE)

Single row (horizontal array):

Copy

=RANDARRAY(1,5,1,100,TRUE)

Real-World Applications of RANDARRAY

1. Generate Sample Data for Testing

Create a realistic price dataset:

Copy

=RANDARRAY(100,1,10,500,FALSE)

2. Random Date Generation

To generate random dates within a specific range:

Copy

=WORKDAY(DATE(2024,1,1),RANDARRAY(10,1,0,365,TRUE))

3. Random Selection with CHOOSE

Create random selections from a list:

Copy

=CHOOSE(RANDARRAY(5,1,1,3,TRUE),”Apple”,”Orange”,”Banana”)

Combining RANDARRAY with Other Excel Functions

1. Random Sorting

To randomly sort a range of data:

Copy

=SORTBY(A1:A10, RANDARRAY(ROWS(A1:A10)))

2. Random Sampling

To select random items from a dataset:

Copy

=FILTER(A1:A100,RANDARRAY(100,1)<=0.1)

3. Weighted Random Selection

Create weighted random selections:

Copy

=INDEX(A1:A10,MATCH(RAND(),CUMSUM(B1:B10)/SUM(B1:B10),1))

Performance Considerations

When working with RANDARRAY, keep these points in mind:

  1. Array Size Impact
  • Limit array sizes to necessary dimensions
  • Consider using smaller arrays for frequent calculations
  1. Calculation Behavior
  • RANDARRAY recalculates with every worksheet change
  • Use F9 to manually recalculate when needed
  1. Memory Usage
  • Large arrays can impact spreadsheet performance
  • Consider using dynamic array formulas sparingly

Next Steps

Now that you understand how to use RANDARRAY effectively, you can create dynamic, data-driven spreadsheets with random values for testing, simulation, or analysis. To take your spreadsheet capabilities even further, consider using Coefficient to connect your random data generations with real-time data from your business systems.

Get started with Coefficient to enhance your spreadsheet automation and connect your random data generations with live business data sources.

Sync Live Data into Your Spreadsheet

Connect Google Sheets or Excel to your business systems, import your data, and set it on a refresh schedule.

Try the Spreadsheet Automation Tool Over 500,000 Professionals are Raving About

Tired of spending endless hours manually pushing and pulling data into Google Sheets? Say goodbye to repetitive tasks and hello to efficiency with Coefficient, the leading spreadsheet automation tool trusted by over 350,000 professionals worldwide.

Sync data from your CRM, database, ads platforms, and more into Google Sheets in just a few clicks. Set it on a refresh schedule. And, use AI to write formulas and SQL, or build charts and pivots.

Julian Alvarado Content Marketing
Julian is a dynamic B2B marketer with 8+ years of experience creating full-funnel marketing journeys, leveraging an analytical background in biological sciences to examine customer needs.
500,000+ happy users
Wait, there's more!
Connect any system to Google Sheets in just seconds.
Get Started Free

Trusted By Over 50,000 Companies