Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rand - Randbetween

Status
Not open for further replies.

bojzon

IS-IT--Management
Sep 18, 2003
25
SI
How create in VBA "MyRAND" for random selecting only some noncontiguous (40) numbers. (ex. 20,25,30,40,41,....75..)

Round(RAND() * (40-1)+1, 0) > use contiguos numbers in between 1 to 40.


Thanks for advice
 
Put your list of non-contiguous numbers into an array, then do a Rand to select the array index

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
How (VBA) create dinamic list (input non-contiguous numbers differ each time) for "dinamic array - index"?

Thanks
 
The following code generate 40 numbers in the range 1-100:
For i = 1 To 40
Debug.Print Round(99 * Rnd() + 1, 0)
Next

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top