- To post as a guest, your comment is unpublished.· 1 years agoHi Mark, Were you able to find a solution for getting more than 1 random employee with conditions?
Kutools for Excel is a powerful add-in that frees you from performing time-consuming operations in Excel, such as combine sheets quickly, merge cells without losing data, paste to only visible cells, count cells by color and so on. 300+ powerful features / functions for Excel 2019, 2016, 2013, 2010, 2007 or Office 365!
It enables tabbed browsing, editing, and managing of Microsoft Office applications. You can open multiple documents / files in a single tabbed window, such as using the browser IE 8/9/10, Firefox, and Google Chrome. It's compatible with Office 2019, 2016, 2013, 2010, 2007, 2003 or Office 365. Demo
Kutools for Outlook is a powerful add-in that frees you from time-consuming operations which majority of Outlook users has to perform daily! It can save your time from using Microsoft Outlook 2019, 2016, 2013, 2010 or Office 365!
Kutools for Word is a powerful add-in that frees you from time-consuming operations which majority of Word users have to perform daily! It can save your time from using Microsoft Word / Office 2019, 2016, 2013, 2010, 2007, 2003 or Office 365!
Restores the old look and menus of Office 2003 to Microsoft Office 2019, 2016, 2013, 2010, 2007 or Office 365. Don’t lose time in finding commands on the new Ribbon. Easy to deploy to all computers in enterprises and organizations.
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.
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.
|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!