ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Random select entries (https://www.excelbanter.com/excel-discussion-misc-queries/96272-random-select-entries.html)

brodiemac

Random select entries
 
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?

Owen

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?



CJ

Random select entries
 
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




All times are GMT +1. The time now is 05:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com