View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Owen
 
Posts: n/a
Default Random select entries

Assuming the list of entries are in column a the code below will
highlight as many as you specify. It's also set up to summarize the
data it highlighted in column b

HTH
Owen


Sub RandomSelect()

Dim iCount As Long
Dim i As Long
Dim iOffset As Long
Dim iRange As Long
Dim bUnique As Boolean

iRange = Application.WorksheetFunction.Count(Range("A:A"))
iCount = InputBox("Enter the number of random values to pull")


Range("A:A").Interior.ColorIndex = xlNone
Range("b:b").ClearContents
For i = 1 To iCount

Do
iOffset = Rnd() * iRange
If Range("A1").Offset(iOffset, 0).Interior.ColorIndex = 6 Then
bUnique = False
Else
Range("A1").Offset(iOffset, 0).Interior.ColorIndex = 6
bUnique = True
Range("b1").Offset(i, 0) = Range("A1").Offset(iOffset, 0)
End If
Loop Until bUnique = True

Next i

End Sub

brodiemac wrote:
I have a list of names, phone numbers, etc. The list is over 5,000 entries
long. I need to randomly select 1100 of them. Is there a way to do this in
excel? I know how to randomly select one.

Better still, can I randomly select and highlight 1100 entires?