Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excell Random number

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Excell Random number

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

"Lacoran" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 837
Default Excell Random number

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

"Lacoran" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Addding a Random number to a fixed number..... Dermot Excel Discussion (Misc queries) 6 August 20th 06 12:17 PM
How can I match a random number with closest number from sequence? Matt Excel Worksheet Functions 4 August 3rd 06 01:22 AM
same number appears in a random number generator Carmel Excel Worksheet Functions 4 May 28th 06 12:22 AM
Generating (in a random order)each number once from a given number Neil Goldwasser Excel Worksheet Functions 2 December 2nd 05 11:27 PM
How do I find random number in list of random alpha? (Position is. jlahealth-partners Excel Discussion (Misc queries) 0 February 8th 05 05:31 PM


All times are GMT +1. The time now is 06:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"