Excel Randomly Picking a Number: Using RANDBETWEEN and INDEX

Explain how to randomly pick one value from a set of data in Excel: use RANDBETWEEN to generate a random index, then use INDEX to retrieve the corresponding content. Cover the formula syntax, how to fix the result, common error troubleshooting, and approaches for drawing without repetition.

Key Points of This Article

  • Random selection picks values by sequence number: use RANDBETWEEN to generate a random sequence number between 1 and the number of data rows, then pass it to INDEX to retrieve the corresponding content.
  • The data range in the formula should first use ROWS to calculate the number of rows, so the upper limit does not need to be changed manually when data is added or removed.
  • RANDBETWEEN changes every time the sheet recalculates; when you need to fix the result, copy it and use Paste Special to paste as values.
  • Before drawing, confirm that the range has no blank cells and that the header row is not included in the calculation; otherwise the draw may return a blank or a header.
  • To draw several items at once without repetition, assign each row a RAND random number, sort by it, and then take the first few rows.

Lottery draws, grouping, roll calls, and sampling for inspection often require randomly picking a number or a person from a set of data. Many people instinctively pick by hand or simply choose a number at random, which easily introduces subjective bias. In Excel, accomplishing this with a formula is not complicated; the core requires only two functions: RANDBETWEEN generates a random sequence number, and INDEX retrieves the corresponding value by that number.

This article is written for people who need to do random selection in Excel spreadsheets, such as teachers who want to call on students at random, operations staff who need to draw a winner, or quality inspectors who need to randomly pick several records for review. After reading it, you will be able to write a complete random selection formula, understand why the results change and how to make them stay fixed, and know where to start looking when a selection goes wrong.

How do I randomly pick one number from a set of data? One-sentence answer

If the data is arranged in a single column with no blank rows in between, you can use INDEX to retrieve a value directly, with the position number generated by RANDBETWEEN, and this will randomly pick one result. The table below lists common situations and the corresponding approaches.

Your situationRecommended PracticesCause
The data is a continuous list of names or numbers.INDEX with RANDBETWEEN(1,ROWS(range))The structure is simple; after data is added or removed, only the area needs to be adjusted.
I need random integers, not values taken from a listUse RANDBETWEEN(lower bound, upper bound)Get the result in one step, without INDEX
The result must remain unchanged after each extraction.After drawing (the lottery/draw), copy, then use Paste Special and choose Values.Random functions change with each worksheet recalculation; paste as values to fix the results.
Empty cells mixed in the dataFirst filter out the blank rows, or switch to counting non-empty cells instead.A random number might land on a blank, resulting in an empty result.
Need to draw multiple items at once, with no duplicatesAdd a RAND helper column and sort, then take the top few rowsSorting by random numbers is equivalent to shuffling the order.

Before You Begin: Confirm These Points

Before you start writing the formulas, spend a minute confirming the following items. This can avoid most of the rework.

  1. Whether the data range is continuous. INDEX calculates positions by row count. If there are blank rows in between, a blank row has the same chance of being drawn as any other row, and the result will be blank. The range should be organized into a continuous block first.
  2. Whether the range includes the header row. If the range starts at the header row, the header can be drawn too. The formula's starting point should begin at the row of the first real data record.
  3. Whether the random results will change. RANDBETWEEN and RAND are volatile functions. Almost any change to the worksheet can trigger a recalculation, and the results will change with it. If you need to keep the results, fix them (paste as values) after the draw.
  4. Whether duplicates are allowed. When drawing only one item, the duplicate issue does not arise. When drawing multiple items, you must decide whether to draw with replacement or without replacement, as the formulas for the two differ.
  5. Whether the process needs to be documented. If the draw results must be explained to others or kept on file, it is advisable to retain the random sequence numbers and the original order of the list so that the process can be checked later.

Steps to Pick a Random Value in Excel Using INDEX and RANDBETWEEN

The following uses a column of 20 names as an example, with the names placed in cells A2 to A21.

  1. Organize the data. Put the items to be extracted in one column, for example A2:A21, make sure there are no blank rows in between, and put the title in A1.
  2. Count the rows. In an empty cell, enter =ROWS(A2:A21); the result should be 20. This step confirms the range, and the upper limit of the later formula refers to it directly.
  3. Generate a random number. In another cell, enter =RANDBETWEEN(1,20). It returns a random integer between 1 and 20, and this number is the position to extract.
  4. Combine into one formula. Replace the upper limit with the ROWS function and write =INDEX(A2:A21,RANDBETWEEN(1,ROWS(A2:A21))). INDEX returns the content of the Nth cell in A2:A21, where N is determined by RANDBETWEEN.
  5. Draw again. Each time you press F9, RANDBETWEEN recalculates and the result changes. To draw more times, press it more times.
  6. Fix the result. After confirming the result you want to keep, copy that cell, then use Paste Special and choose Values. The original formula is replaced by a static result, which will no longer change.

Verify item by item after completion

After the extraction results are produced, take some time to verify them, especially when they are to be used in formal settings.

Inspection itemHow do you see it?What should I do if I have a problem?
Is the drawn result within the data range?Check against the list to confirm the results are indeed within A2:A21.If an error value appears, check whether the range reference is written incorrectly and whether the row number exceeds the data.
Did you draw a title or a blank?Is the result a header text or an empty cell?Change the starting point to the first row of real data, delete the blank rows in between, and then recalculate.
Do formulas change accordingly after data is added or removed?After adding a few rows of data, observe the result of ROWSIf the range does not cover the new data, reselect the range, or organize the range into a table and then reference it.
Is there a pattern to multiple draws?Press F9 several times in a row and observe whether the results are distributed across the entire list.If some people never appear, check whether the maximum ID is smaller than the number of data rows
Is the result correct after fixing?Check the cells after pasting as values; they no longer show formulasIf it is still a formula, copy it again and paste it as values

Machine-generated random results also need manual review. If the list comes from an external file, misalignment during import, merged cells, and hidden rows may all cause the list to differ from the actual data.

📊 Core Comparison

Randomly select three common approaches, each suited to different scenarios:

MethodSuitable scenariosNotes
RANDBETWEEN with INDEXPick one person or item from a list. The formula is short and easy to understand.Ranges must be contiguous, and the range is calculated using ROWS.
RAND matching with sortingDraw multiple non-repeating results at once, for example, select five winners.Sorting changes the original order, so back up the list before you start.
Using RANDBETWEEN directlyGenerate random numbers, such as randomly assigning numbers or drawing a number within a rangeThis doesn't involve list content, so the text can't be extracted directly.

Advanced: Draw Multiple Items Without Repetition

To draw 3 people at random without repetition, enter =RAND() in column B on each row and fill it down to assign a random number to each name. Then select columns A and B and sort by column B in ascending order. After sorting, the first 3 rows are the randomly drawn result. Sorting changes the original order, so back up the original list before you start.

If the list comes from a PDF, such as a scan or an exported roster, you can first run OCR with the desktop client's PDF editor, then export the content to Excel and process it according to the steps above. Check the recognized text line by line, since both OCR and machine conversion can produce typos or misaligned rows.

❓ Frequently Asked Questions (FAQ)

1. Why does the result of RANDBETWEEN change every time I open the file?

RANDBETWEEN is a volatile function: it generates a new random number whenever the worksheet recalculates, including when you open the file, edit other cells, or press F9. To keep a fixed result, copy the cell and paste it as values.

2. Is the drawn number really random?

Excel's random functions are suitable for everyday selection tasks, such as calling on students, holding prize draws, or forming groups. For occasions with strict fairness requirements, it is recommended to publish the formula and the list before the draw, and to keep screenshots or records of the draw so that others can verify the results.

3. How do I write the formula when there is a blank row in the middle of the list?

The safest approach is to first delete the blank rows or reorganize the data into a continuous range. If that cannot be done for the moment, you can use a filter to display only the non-blank rows and then calculate on the visible content separately, but a plain INDEX formula will count the blank rows in its sequence numbers as well.

4. What if I want to extract a range rather than a whole column?

Change the range to whatever area you need. For example, if you only want to draw from B5 to B30, write =INDEX(B5:B30,RANDBETWEEN(1,ROWS(B5:B30))). The more precise the range, the less likely you are to draw invalid content.

📝 Summary

To randomly draw a value from a set of data in Excel, the core approach is to use RANDBETWEEN to generate a sequence number, use INDEX to retrieve the value by that number, and use ROWS to ensure the range adjusts as the data changes. After drawing, remember to paste the results as values to fix them, and check the list and area against a checklist, so that the random drawing process can withstand review.

Open OmniDoc and process your spreadsheet file

Updated 2026-11-28