Function Pairs(howmany As Long) As String
Static origprs As Variant
Dim remprs As Variant, num As Variant, thesenums As Variant
Dim s As String, tmp As String
Dim i As Long, j As Long
Dim sl
ReDim sl(1 To 2, 1 To howmany)
Application.Volatile
Randomize
If IsEmpty(origprs) Then origprs = Split("/5/10/ /5/20/ /5/30/ /10/20/ /10/40/ /20/30/ /20/50/ /30/60/ /40/50/ /40/70/ /50/60/" _
& " /50/80/ /60/90/ /70/80/ /70/100/ /80/90/ /80/110/ /90/120/ /100/110/ /100/130/ /110/120/" _
& " /110/140/ /120/150/ /130/140/ /130/160/ /140/150/ /140/170/ /150/180/ /160/170/ /160/190/" _
& " /170/180/ /170/200/ /180/210/ /190/200/ /190/220/ /200/210/ /200/230/ /210/240/ /220/230/" _
& " /220/250/ /230/240/ /230/260/ /240/270/ /250/260/ /250/280/ /260/270/ /260/290/ /270/300/" _
& " /280/290/ /280/310/ /290/300/ /290/320/ /300/330/ /310/320/ /310/340/ /320/330/ /320/350/ /330/360/")
remprs = origprs
For i = 1 To howmany
If UBound(remprs) = -1 Then
Pairs = "Error"
Exit Function
End If
s = remprs(Int(Rnd() * (UBound(remprs) + 1)))
s = Mid(s, 2, Len(s) - 2)
thesenums = Split(s, "/")
For Each num In thesenums
remprs = Filter(remprs, "/" & num & "/", False)
Next num
For j = i To 1 Step -1
If j > 1 And sl(1, IIf(j = 1, 1, j - 1)) > CInt(thesenums(0)) Then
sl(1, j) = sl(1, j - 1)
sl(2, j) = sl(2, j - 1)
Else
sl(1, j) = CInt(thesenums(0))
sl(2, j) = CInt(thesenums(1))
Exit For
End If
Next j
Next i
For i = 1 To howmany
tmp = tmp & ", " & sl(1, i) & "/" & sl(2, i)
Next i
Pairs = Mid(tmp, 3)
End Function