Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / December 2007

Tip: Looking for answers? Try searching our database.

Excell Random number

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lacoran - 13 Dec 2007 17:10 GMT
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
JLGWhiz - 13 Dec 2007 17:21 GMT
You could use On Error GoTo Restart:

example:

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

> 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
Jerry W. Lewis - 13 Dec 2007 17:30 GMT
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

> 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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.