Random select entries

G

Guest

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?
 
O

Owen

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
 
G

Guest

Hey OWEN,
Can you please explain this step by step including which cells to put which
formulas in? I'm having a little difficulty understanding the process.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top