![]() |
random non-repeating names
I have a sheet of names (all ID'd 1-700), and I would like to randomly pull 35 names from the list with out any repeats. Where should I begin. -- rivet ------------------------------------------------------------------------ rivet's Profile: http://www.excelforum.com/member.php...o&userid=20022 View this thread: http://www.excelforum.com/showthread...hreadid=346087 |
random non-repeating names
Assuming your IDs are in col A and the names are in col B, this sub
will pick 35 unique names and put them in col C. Sub GetNames() Dim x As Integer Dim intNum As Integer Dim arrNames(34) As String, strName As String Dim blnNameFound As Boolean x = 0 Do Until x = 35 blnNameFound = False Randomize (Timer) '--Randomly pick the ID intNum = Rnd(1) * 700 + 1 '--Get the corresponding name strName = Cells(intNum, 2) '--Check the array for that name and set a boolean to true if found For y = 0 To 34 If strName = arrNames(y) Then blnNameFound = True Exit For End If Next y '--If the name was not found, add it to the array If blnNameFound = False Then arrNames(x) = strName x = x + 1 End If Loop Does this help? 'Put the 35 names in column C For x = 0 To 34 Cells(x + 1, 3) = arrNames(x) Next End Sub |
random non-repeating names
Random Selection
http://www.tushar-mehta.com/excel/ne...ion/index.html -- Regards, Tushar Mehta www.tushar-mehta.com Multi-disciplinary business expertise + Technology skills = Optimal solution to your business problem Recipient Microsoft MVP award 2000-2005 In article , rivet.1kkd04 @excelforum-nospam.com says... I have a sheet of names (all ID'd 1-700), and I would like to randomly pull 35 names from the list with out any repeats. Where should I begin. -- rivet ------------------------------------------------------------------------ rivet's Profile: http://www.excelforum.com/member.php...o&userid=20022 View this thread: http://www.excelforum.com/showthread...hreadid=346087 |
All times are GMT +1. The time now is 02:55 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com