Randomize a list in ExcelSorting is an important feature that helps to create different algorithms. Because of its incredible usage, Microsoft Excel has provided other sorting options, including ascending or descending sorting, color sorting, as well as custom sorting. However, it does not offer one important sorting feature, i.e., the random sort. While working with Excel, situations occur where you need to randomize data such as winning lottery tickets, allocation of night shift, etc.; in such cases, the random sort option comes very handy. In this tutorial, we will cover a handful of different random sorting options using Excel inbuilt functions such as RAND(), RANDARRAY() and SORTBY () and their step-by-step implementation in Excel. Randomize in Excel using RAND() formulaThough Randomizing a list in excel is an important feature but is no inbuilt function to perform this operation in Excel. However, we can create our own formula to generate random numbers. Here, we can take use the inbuilt RAND function to incorporate this function. The RAND() function returns an automatically generated random number in the selected cell. Syntax RAND() NOTE: Every time a cell in your worksheet is recalculated, a new random number is generated.In the following image, we have taken a list of names in column A. What if we want to randomise this list and set the order of the name automatically? Below given are the step-by-step implementation to generate random numbers which will automatically randomise the above list: STEP 1: Insert a helper columnAdd a new column next to column A. We will apply the formula of randomization in this column. However, if your dataset consists of a single column, skip this step. Step 2: Apply the RAND() functionNext, we will incorporate the inbuilt RAND() function in Excel. RAND() function creates a random number in your Excel worksheet. Start your formula with = and write the RAND() function. Press enter and it will automatically generate a random number. Step 3: Copy the formula down the cells.Drag the formula down the column to replicate it down the cells. The fastest way to do this is by double-clicking the fill handle. Step 4: Sort the name is an OrderNext, we will sort the helper column in ascending order which we can recently filled with random numbers. (If required you can also sort the numbers in a series of descending order. But the problem is it will move the column headers at the bottom of the table, which is not ideal).
Step 5: Excel will generate the random numbers.As a result, Excel will automatically expand your selection and it will sort the list of names specified in column A. Refer to the following screenshot. Points to Remember:
Randomising using multiple functionsExcel provides multiple ways to perform a task. If you are using version Excel 365 or Excel 2021, you can incorporate the combination of RANDARRAY(), SORTBY() and ROWS() functions to randomize a list in your Excel worksheet. Below given are the step-by-step implementation to generate random numbers, which will automatically randomize the above list: Step 1: Generate numbers using RANDARRAYThe first step is to use the RANDARRAY function. This function generates a list of random decimal numbers between 0 and 1. The array below consists of 8 rows and 1 column. Formula: =RANDARRAY (8,1) Note: The RANDARRAY function, entered into cell B1, fills multiple cells. Superb! This feature of automatically filling of data in Excel 365/2021 is called spilling.Step 2: Random Numbers will be generatedAs a result, Excel will generate a list of random numbers. You will have the following output. Step 3: Sort the list with SORTBY functionWithin the same formula we will introduce another function named SORTBY. The built-in SORTBY function is used sort the content of the specified range on the basis of the given array values. By default, the SORT function sorts in ascending order. Formula Used: =SORTBY (A2:A9,B2:B9) You will have the following output: Step 4: Merge RANDARRAY function inside SORTBYSo far, we have applied two different formulas in different places in our worksheet. What if we merge them both in a single formula? Refer to the below formula. Formula Used: =SORTBY(A2:A9,RANDARRAY(8,1)) As a result, the RANDARRAY function will generate a list of random numbers, and later SORTBY will sort the selected names using the corresponding array values. The above formula will randomise the list and will sort the different rows in ascending order. It will return the following output: If you have a longer list of, say, 20 names, change the value from 8 to 20 in the formula shown above, or even better, use the ROWS function. Formula Used: =SORTBY (A2:A9,RANDARRAY(20,1)) Note: The ROWS function simply counts the number of rows in a range.We covered almost everything that will help you to randomise a list in an Excel worksheet. Go ahead and implement the same function and formula to generate a list of random numbers. Next TopicExcel Status Bar |