Random name picker

Jak68

New Member
Joined
Jan 21, 2016
Messages
17
Hello

I hope someone can help me quickly :eeek:

I am looking to create a spreadsheet to be used once a month for a prize draw we do for 3 random names.

I get sent a list of around 100 people and each month I need to randomly pick 3 names from that list (1st prize, 2nd prize and 3rd prize).

Is anyone able to help me :confused:

Thanks
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
I made this code for a nation wide lottery a few months back. I think this can help you

Code:
Dim dict As Object
Set dict = CreateObject("Scripting.Dictionary")

Winners = 3
PopulationNumber = 100
file = 'workbook name
sht = 'sheet name


For i = 1 To Winners

opn:
    Randsample = Int((PopulationNumber- 2) * Rnd + 2)
    If dict.Exists(Randsample) Then GoTo opn
    dict.Add Randsample, i


    Workbooks(file).Worksheets(sht).Rows(Randsample).EntireRow.Copy Destination:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count).Range("A" & i)


Next i


End Sub

Please note that some of these variables need to change depending on your file. I had a userform attached to my workbook which required the user to fill in how many nominees and winners there would be. The code also imports information from the workbook containing the nominees to the workbook that contains the code, to prevent data from being overwritten accidentally.
 
Last edited:
Upvote 0
Thanks for the reply

Now i just need to figure out to set it up correctly as not very savvy regarding macros in Excel...:laugh:
 
Upvote 0
I'd recommend you making a UserForm with a ComboBox for the workbook where your data is in (and if necessary another for the worksheet), and a ComboBox for the number of winners. If the latter is consistent, you can just state the number in the code like I did in the code above. I would determine the number of "players" by checking the last row in the WS. Good luck.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top