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
|