# Select a Name at Random from a List

A useful Excel skill is to be able to select a name at random from a list. This is useful when performing a draw for a sports competition or trying to fairly pick a competition winner.

This can then be expanded upon to randomly select any value from a list.## Set Up the Sheet

The image below show a basic set up of the sheet for selecting a name at random from the list.

The Rand column will be used to randomly pick a number from 0 to 1. The rank column will then be used to uniquely rank the number. This rank will then be used to produce a name from C4:C11 and display it in E4.

## Use the RAND Function

The RAND function will be used to randomly produce a number between 0 and 1. The function should be entered as =RAND() in cells A4:A11.

The RAND function will recalculate every time you perform an action in Excel. This is not what we want. To gain control over when formulas are performed in Excel, you need to switch the formulas from automatic to manual.

1.
Click the **Formulas**
tab on the Ribbon

2.
Click the **Calculation
Options** button in the Calculation group

3.
Select **Manual**
from the list

## Uniquely Rank each Name

The next step is to assign a unique number to each name in the list. The formula below should be entered in cell B4 and copied down to cell B11.

=RANK($A4,$A$4:$A$11)+COUNTIF(B$3:B3,B3)-1

This RANK function is used to rank the number in cell A4 within the range of A4:A11. The second part of the formula is used to make the number unique if there is a conflict.

## Select the Name from the List

In cell E4 a VLOOKUP function will be used to return the name that is assigned the number 1. The VLOOKUP function will look like below.

=VLOOKUP(1,$B$4:$C$11,2,FALSE)

## Create a Button to Run the Formulas

We will create a button to run the formulas in the worksheet by using a macro. First of all, let’s create the button.

1. Click the **Developer** tab on the ribbon

2. Click the **Insert** button in the **Controls** Group

3. Select the **Button (Form Control)** from the list

4. Draw the button onto the worksheet

5. The Assign Macro dialogue box. Click the **New** button

6. The Visual Basic Editor appears and a module is inserted ready for you to enter some VBA code for your button. Enter the code below to calculate the formulas on the worksheet

*Worksheets("Sheet1").Range("A4:B11").Calculate*

*Worksheets("Sheet1").Range("E4").Calculate
*

7. Close the Visual Basic Editor

8. Type a name for your button

The worksheet is completed. Click the button to select a name at random from the list. The formulas will only run when you click the button.

## More by this Author

- 0
Microsoft Excel can do some amazing things. I like to attempt little projects testing what Excel can do. I was asked the other day to simulate a cup draw using Excel and this is the result. This article will give you...

- 1
Although Excel’s greatest strength is its ability to analyse huge amounts of data, it is also great for creating forms. We can create formulas, apply validation rules and use techniques to make our forms user...

- 0
If you are using pictures in your Excel spreadsheet you may be having some difficulty with sorting the pictures along with the other data in the list. The good news is that you can sort pictures in an Excel list just...

## 3 comments

Interesting thanks...voting up!

It is a brilliant way, but I can not get how does this part work (+COUNTIF(B$3:B3,B3)-1) from this formula (=RANK($A4,$A$4:$A$11)+COUNTIF(B$3:B3,B3)-1)

Could you please describe more?

By the way I use countif.

I voted "Awesome"

Thanks

Taleb80

Is there anyway to have it pair people randomly? I need to create teams, where it never pairs the same name with a same name.