Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to randomly select cells based on criteria in Excel?

For example you need to randomly select some data based on one or two criteria from the specified range, how could you solve it in Excel? This article will introduce a couple of solutions for you.

Randomly select cells based on criteria with array formulas

Randomly select cells based on criteria with Kutools for Excel

Randomly select multiple cells/rows/columns from specified range in Excel

You can easily generate a random number with the RAND function in Excel, but do you know how to randomly select a cell from selected range? What if randomly selecting multiple cells? How about randomly selecting multiple rows/columns? Kutools for Excel’s Sort Range Randomly utility provides an easy workaround for you. Full Feature Free Trial 30-day!

ad select randomly 1

Office Tab Enable Tabbed Editing and Browsing in Office, and Make Your Work Much Easier...
Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%
  • Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
  • More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
  • Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
  • Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
  • Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
  • Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
  • More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.

Supposing there is an employee table in Excel as below screenshot shown. And now you need to randomly select one or more employees who work in New York for 3 years from the table.

This method will introduce two array formulas to randomly select cells based on criteria in Excel. Please do as follows:

Randomly select cells based on one criteria

In our example, we need to randomly select one employee who has been working for 3 years. In the cell you will return the employee name randomly, please enter the formula =INDEX(A2:A25,LARGE(IF(C2:C25=F1,ROW(C2:C25)-ROW(C2)+1),INT(RAND()*COUNTIF(C2:C25,F1)+1))), and press the Ctrl + Shift + Enter keys simultaneously.

Note: In above formula, A2:A25 is the list you will randomly select cells from, C2:C25 is the list you will match the criteria in, F1 is the criteria cell, and C2 is the first cell of the list you will match with criteria.

Randomly select cells based on two criteria

To randomly select one employee who has been working in New York for 3 years, please enter the formula =INDIRECT("A"&LARGE(IF($B$2:$B$25=$F$1,IF($C$2:$C$25=$G$1,ROW($A$2:$A$25),0),0), RANDBETWEEN(1,COUNTIFS(B2:B25,F1,C2:C25,G1)))) into the cell you will return random employee’s name, and press the Ctrl + Shift + Enter keys simultaneously.

Note: In above formula, B2:B25 is the list you will match the first criteria in, C2: C25 is the list you will match the second criteria in, F1 is the first criteria cell, G1 is the second criteria cell, and A2:A25 is the list you will randomly select cells from.

note ribbon Formula is too complicated to remember? Save the formula as an Auto Text entry for reusing with only one click in future!
Read more…     Free trial

Actually, we can apply the Filter feature to filter data by criteria easily, and then randomly select cells from the filtered out data. This method will introduce Kutools for Excel’s Sort Range Randomly utility to solve it. Please do as follows:

1. Select the range you will randomly select cells based on criteria, and click Data > Filter.

2. Now the filter arrow is added into each column header. And then filter data by criteria as you need.

In our example, we need to filter out employees working in New York for 3 years, therefore we specify the filter as below screenshot shown:

3. After filtering, select the filtered out list of employees (Column Names in our example) and copy it by pressing the Ctrl + C keys simultaneously; next select a blank cell below filtered range or in a new worksheet, and paste it by pressing the Ctrl + V keys simultaneously.

4. Keep selecting the pasted list, and click Kutools > Range > Sort Range Randomly.

5. In the opening Sort Range Randomly dialog box, go to the Select tab, type the number of cells you will randomly select in the No. of cells to select box, check the Select random cells option, and click the Ok button. See screenshot:

Now the specified number of cells (employees) have been randomly selected based on criteria in the selected list.

Kutools for Excel's Sort Range Randomly can help Excel users to randomly sort all cells in selected range/each row/each column, and randomly select specified number of cells from selected range as well. Click for 60-day free trial, no limitation!


Kutools for Excel includes more than 300 handy tools for Excel, free to try without limitation in 30 days. Download and Free Trial Now!

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Mark · 2 years ago
    This works great when you only need to do this once, but why doesn't it work if you need a list of employees? i have tried to replicate this work where i have a list of 15, but it only works for the first two.

    Any help?
    • To post as a guest, your comment is unpublished.
      Jowan · 9 months ago
      Hi Mark, Were you able to find a solution for getting more than 1 random employee with conditions?