ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Random numbers (https://www.excelbanter.com/excel-programming/284569-random-numbers.html)

ed

Random numbers
 
is there any way of only generating whole numbers within a
certain range with the rnd function

Dan E[_3_]

Random numbers
 
Ed,

Install the Analysis Toolpack add-in
Tools - Add-ins and check off the "Analysis Toolpack".
You might need your install discs depending on your installation.

Once complete you can use the RANDBETWEEN worksheet
function, which does exactly what your asking for.

Dan E

"ed" wrote in message ...
is there any way of only generating whole numbers within a
certain range with the rnd function




Tom Ogilvy

Random numbers
 
=Trunc(rand()*100+1)
drag fill down for as many cells as you need numbers.

will generate whole numbers (not unique) between 1 and 100 inclusive.

--
Regards,
Tom Ogilvy

"ed" wrote in message
...
is there any way of only generating whole numbers within a
certain range with the rnd function




Steve Lerner

Random numbers
 

-----Original Message-----
is there any way of only generating whole numbers within

a
certain range with the rnd function
.

Let's say the range is 5 to 20

the formula would be
=round(5+(rand()*15),0)
copied over the range required.

Tom Ogilvy

Random numbers
 
This formula will generate whole numbers between 5 and 20 inclusive, but
both 5 and 20 have half the probability of occurring as the numbers 6 to 19
inclusive.

=Trunc(rand()*15+5)

will fix this.

--
Regards,
Tom Ogilvy

"Steve Lerner" wrote in message
...

-----Original Message-----
is there any way of only generating whole numbers within

a
certain range with the rnd function
.

Let's say the range is 5 to 20

the formula would be
=round(5+(rand()*15),0)
copied over the range required.





All times are GMT +1. The time now is 01:27 PM.

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