ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Random numbers from several ranges (https://www.excelbanter.com/excel-worksheet-functions/193972-random-numbers-several-ranges.html)

ChrisSafety

Random numbers from several ranges
 
How can I set up one formula to randomly give me a number from multiple
ranges? For example, I have 2 ranges. One is 105 though 128 and the other is
244 through 286. I need to randomly select one number from either range. I
have tried the =RANDBETWEEN function, but I can't get it to work for multiple
ranges. Please help! Thank You
Chris

John C[_2_]

Random numbers from several ranges
 
You could set up multiple randbetween statements with an IF statement.

If each range is weighted equally:

=IF(RANDBETWEEN(1,2)=1,RANDBETWEEN(105,128),RANDBE TWEEN(244,286))

If each possibility in each range is weighted equally:

=IF(RANDBETWEEN(1,67)<25,RANDBETWEEN(105,128),RAND BETWEEN(244,286))


--
John C


"ChrisSafety" wrote:

How can I set up one formula to randomly give me a number from multiple
ranges? For example, I have 2 ranges. One is 105 though 128 and the other is
244 through 286. I need to randomly select one number from either range. I
have tried the =RANDBETWEEN function, but I can't get it to work for multiple
ranges. Please help! Thank You
Chris


ChrisSafety

Random numbers from several ranges
 
Thank you so much! It worked perfectly!

"John C" wrote:

You could set up multiple randbetween statements with an IF statement.

If each range is weighted equally:

=IF(RANDBETWEEN(1,2)=1,RANDBETWEEN(105,128),RANDBE TWEEN(244,286))

If each possibility in each range is weighted equally:

=IF(RANDBETWEEN(1,67)<25,RANDBETWEEN(105,128),RAND BETWEEN(244,286))


--
John C


"ChrisSafety" wrote:

How can I set up one formula to randomly give me a number from multiple
ranges? For example, I have 2 ranges. One is 105 though 128 and the other is
244 through 286. I need to randomly select one number from either range. I
have tried the =RANDBETWEEN function, but I can't get it to work for multiple
ranges. Please help! Thank You
Chris


Jarek Kujawa[_2_]

Random numbers from several ranges
 
1. have you tried to use named ranges?

in Excel 2003 Insert-Name-Define

2. another option might be:
http://www.tushar-mehta.com/excel/ti..._argument.html


All times are GMT +1. The time now is 04:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com