ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   What function will give me a random full number from 1 to 6 (https://www.excelbanter.com/excel-programming/328965-what-function-will-give-me-random-full-number-1-6-a.html)

Audrey

What function will give me a random full number from 1 to 6
 


Harald Staff

What function will give me a random full number from 1 to 6
 
=1+INT(RAND()*6)

HTH. Best wishes Harald

"Audrey" skrev i melding
...




Tom Ogilvy

What function will give me a random full number from 1 to 6
 
VBA
num = int(rnd()*6+1)

Excel
=trunc(rand()*6+1)

--
Regards,
Tom Ogilvy

"Audrey" wrote in message
...




Ron Rosenfeld

What function will give me a random full number from 1 to 6
 
On Sun, 8 May 2005 06:06:04 -0700, Audrey
wrote:

and just for another method, if you have the Analysis ToolPak installed:

=RANDBETWEEN(1,6)

If this function is not available, and returns the #NAME? error, install and
load the Analysis ToolPak add-in.

On the Tools menu, click Add-Ins.
In the Add-Ins available list, select the Analysis ToolPak box, and then click
OK.
If necessary, follow the instructions in the setup program.

--ron

Darren Hill[_3_]

What function will give me a random full number from 1 to 6
 
In the formulas below, it struck me as odd you used INT in the VBA one but
avoided it in the Excel one. Is there a programming reason for this, or is
it just a personal preference?

Thanks
Darren



On Sun, 8 May 2005 09:50:35 -0400, Tom Ogilvy wrote:

VBA
num = int(rnd()*6+1)

Excel
=trunc(rand()*6+1)


Tom Ogilvy

What function will give me a random full number from 1 to 6
 
Trunc is more descriptive, but not available in VBA. The INT
worksheetfunction has no relation to the VBA INT function.

--
Regards,
Tom Ogilvy

"Darren Hill" wrote in message
news:opsqgwcamved89cl@omega...
In the formulas below, it struck me as odd you used INT in the VBA one but
avoided it in the Excel one. Is there a programming reason for this, or is
it just a personal preference?

Thanks
Darren



On Sun, 8 May 2005 09:50:35 -0400, Tom Ogilvy wrote:

VBA
num = int(rnd()*6+1)

Excel
=trunc(rand()*6+1)




Darren Hill[_3_]

What function will give me a random full number from 1 to 6
 
Thanks for clarifying.

Darren

On Sun, 8 May 2005 21:31:09 -0400, Tom Ogilvy wrote:

Trunc is more descriptive, but not available in VBA. The INT
worksheetfunction has no relation to the VBA INT function.




--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/


All times are GMT +1. The time now is 10:16 AM.

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