Can you tell me a best script / program that will pull a winner at random.
These are all entrants to a competition and one winner needs to be chosen randomly.
The data in Excel sheet. I want to run the script against excel.
Can you tell me a best script / program that will pull a winner at random.
These are all entrants to a competition and one winner needs to be chosen randomly.
The data in Excel sheet. I want to run the script against excel.
save as CSV then
in python:
import random
fd = open(csv_file)
lines = fd.readlines()
line_num = random.randrange(0,len(lines)-1)
print 'winner: ', lines[line_num]
The following assumes your list of entrants is in a range named "Entrants". Naturally, the usual caveats about system-generated random numbers not exactly being random apply - should be fine for local/small scale fun competition, probably not the solution for a national lottery.
Sub PickWinner()
Dim winner As String
winner = Range("Entrants").Cells(Int(Rnd() * (Range("Entrants").Count) + 1), 1)
Debug.Print winner
End Sub