Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Non repeating random numbers Rowland Excel Worksheet Functions 3 January 29th 07 11:31 PM
random numbers repeating Harlan Grove Excel Discussion (Misc queries) 2 January 23rd 07 11:30 PM
random numbers repeating Ashkan Excel Discussion (Misc queries) 0 January 23rd 07 05:42 AM
random number without repeating? nonoi via OfficeKB.com Excel Worksheet Functions 2 July 11th 05 05:59 AM
Random Number Non Repeating ... a_ryan1972 Excel Discussion (Misc queries) 3 April 6th 05 09:26 PM


All times are GMT +1. The time now is 10:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"