Sub GenerateRandomPicks()
Dim lR As Long, R As Range, T As Double
Dim C As Integer, d As Object, S1 As Worksheet, S2 As Worksheet
Set S1 = ActiveSheet
On Error Resume Next
Set R = S1.Application.InputBox("Select a range of values with your mouse", Type:=8)
If R Is Nothing Then Exit Sub
If R.Columns.Count <> 1 Then
MsgBox "Please select a single column only."
Exit Sub
End If
On Error GoTo 0
C = Application.InputBox("How many values?", Type:=1)
Set d = CreateObject("Scripting.dictionary")
d.RemoveAll
On Error Resume Next
Application.DisplayAlerts = False
Sheets("Random").Delete
On Error GoTo 0
Set S2 = Sheets.Add(after:=S1)
S2.Name = "Random"
With S2.Columns("A")
Do
T = WorksheetFunction.RandBetween(1, R.Rows.Count)
If S1.Cells(T, 2).Value < 100 And Not d.exists(CStr(T)) Then
n = n + 1
d.Add CStr(T), n
.Cells(n).Value = S1.Cells(T, 1).Value
End If
Loop Until n = C Or d.Count = WorksheetFunction.CountIf(R, "<100")
If d.Count = WorksheetFunction.CountIf(R, "<100") And n < C Then
.Cells(n + 1).Value = "No more values meet the criteria"
End If
End With
End Sub