Random number - multiple iterations

SvenB

New Member
Joined
Dec 21, 2016
Messages
28
Hello. I need your advice related to the following matter. I want to generate a random number for multiple times say 100, take the average of all 100 iterations, and put it into a particular cell.
I am currently using this simple code for generating a random number.

Code:
Sub RandomNo()


Dim rng As Range


Set rng = Range("B8")
rng.Value = Rnd() * ((-1) ^ Int(Rnd() * 10)) * 0.05


End Sub

How could I do that? Thank you.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hi, there are probably lots of ways of doing this, but one way (maybe not the best way) would be to write a random value into 100 cells, not just one, and then have a simple formula that calculates the average of those 100 cells.
This has the advantage in that if the result is surprising, you can audit the individual values, to check.

Another thought, I'm not a statistician but if the Rnd() function is genuinely random, then presumably as the number of iterations increases, the average result will probably trend towards 0.5.
 
Upvote 0

Forum statistics

Threads
1,223,947
Messages
6,175,563
Members
452,652
Latest member
eduedu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top