Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default How to Restrict Random Numbers?

How can I exclude certain numbers from the RANDBETWEEN() function? For
example, I might want to generate a random integer between 1 and 10 that
isn't 2, 5 or 7.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,624
Default How to Restrict Random Numbers?

One way:

=CHOOSE(INT(RAND()*7)+1,1,3,4,6,8,9,10)

In article ,
Mister wrote:

How can I exclude certain numbers from the RANDBETWEEN() function? For
example, I might want to generate a random integer between 1 and 10 that
isn't 2, 5 or 7.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default How to Restrict Random Numbers?

Thanks, but this won't quite do what I need. I should have explained better.
You see, someone who uses this workbook will, ideally, be able to able to
select with check box form controls which numbers will be excluded durning
any given calculation. So they could select 2 and 9 to be excluded,
calculate, then select 7, 8 and 10, calculate, and so on.

"JE McGimpsey" wrote:

One way:

=CHOOSE(INT(RAND()*7)+1,1,3,4,6,8,9,10)

In article ,
Mister wrote:

How can I exclude certain numbers from the RANDBETWEEN() function? For
example, I might want to generate a random integer between 1 and 10 that
isn't 2, 5 or 7.


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15,768
Default How to Restrict Random Numbers?

Maybe something like this:

A2:A11 = 1,2,3,4,5,6,7,8,9,10

B2:B11 = checkboxes linked to the same cells as each checkbox is "in"

C2:C11: =RAND()

To get the random number try this array formula** :

=INDEX(A2:A11,MATCH(MAX(IF(B2:B11=FALSE,C2:C11)),C 2:C11,0))

** array formulas need to be entered using the key combination of
CTRL,SHIFT,ENTER (not just ENTER)

Note that when you check/uncheck different checkboxes this will cause the
random number to change since RAND is a volatile function. You may want to
set calculation to manual and then hit F9 after you make your selections.

--
Biff
Microsoft Excel MVP


"Mister" wrote in message
...
Thanks, but this won't quite do what I need. I should have explained
better.
You see, someone who uses this workbook will, ideally, be able to able to
select with check box form controls which numbers will be excluded durning
any given calculation. So they could select 2 and 9 to be excluded,
calculate, then select 7, 8 and 10, calculate, and so on.

"JE McGimpsey" wrote:

One way:

=CHOOSE(INT(RAND()*7)+1,1,3,4,6,8,9,10)

In article ,
Mister wrote:

How can I exclude certain numbers from the RANDBETWEEN() function? For
example, I might want to generate a random integer between 1 and 10
that
isn't 2, 5 or 7.




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
getting numbers divisible by 4 from random numbers in ascending order ramana Excel Worksheet Functions 6 June 19th 07 06:41 PM
I want random numbers generated without repeating numbers Johncobb Excel Worksheet Functions 2 September 7th 06 04:52 PM
Can Excel pick random numbers from 1-300 and not repeat numbers? Julian Excel Discussion (Misc queries) 1 June 7th 06 07:17 AM
Non-random numbers generated by excel's data analysis random gener Allie Excel Worksheet Functions 10 September 17th 05 06:19 AM
Non-random numbers generated by excel's data analysis random gener Harlan Grove Excel Discussion (Misc queries) 2 September 13th 05 04:06 PM


All times are GMT +1. The time now is 01:05 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"