Excell Random number

L

Lacoran

I am using the rand() function in Visual basic to find a specific number on a
list and bring up the value from 2 cells over. I have got all that but the
list does not contain all number from 1 to 100. for example there is no 23
so when rand comes up with 23 the macro gets an error. is there a way in VB
that if it get that error it goes to the next integer 1 higher and
conditiunes that until it gets a number that works
 
J

JLGWhiz

You could use On Error GoTo Restart:

example:

Sub Rand#()
Restart:
'your regular code
On Error GoTo Restart:
'execute Rand()
 
J

Jerry W. Lewis

If you assign a random number to each of the used ID numbers, and sort both
by the random numbers, then you will have a random ordering of the avilable
numbers.

Jerry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top