ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Random Number in VBA (https://www.excelbanter.com/excel-programming/345486-random-number-vba.html)

C. Roenbaugh

Random Number in VBA
 
I need a random number generated in a UDF. I tried using
worksheetfunction.rand() without success. The number needs to be
uniformly distributed between 0 and 1. Any ideas?

Thanks

Chris Roenbaugh


Tom Ogilvy

Random Number in VBA
 
Public Function MyFunc()
num = rnd
MyFunc = num
End Function

--
Regards,
Tom Ogilvy


"C. Roenbaugh" wrote in message
oups.com...
I need a random number generated in a UDF. I tried using
worksheetfunction.rand() without success. The number needs to be
uniformly distributed between 0 and 1. Any ideas?

Thanks

Chris Roenbaugh




Gary''s Student

Random Number in VBA
 
=Rnd()


"C. Roenbaugh" wrote:

I need a random number generated in a UDF. I tried using
worksheetfunction.rand() without success. The number needs to be
uniformly distributed between 0 and 1. Any ideas?

Thanks

Chris Roenbaugh



Tom Ogilvy

Random Number in VBA
 
Think you mean

=Rand()

But he appeared to be familiar with that since he was trying to use it in
VBA.

--
Regards,
Tom Ogilvy


"Gary''s Student" wrote in message
...
=Rnd()


"C. Roenbaugh" wrote:

I need a random number generated in a UDF. I tried using
worksheetfunction.rand() without success. The number needs to be
uniformly distributed between 0 and 1. Any ideas?

Thanks

Chris Roenbaugh





C. Roenbaugh

Random Number in VBA
 
tHANKS



All times are GMT +1. The time now is 05:19 PM.

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