The following code sample demonstrates how to generate random numbers that fall within a specified range.
Function RandomNumber(nMin, nMax)
RandomNumber = Null
If Not IsNumeric(nMin) Then Exit Function
If Not IsNumeric(nMax) Then Exit Function
If nMin >= nMax Then Exit Function
Randomize
RandomNumber = Int((nMax - nMin + 1) * Rnd + nMin)
End Function