Simulations

gaw1za

New Member
Joined
Dec 20, 2004
Messages
14
Hi, is there is a simple macro for the following:

Say I have random numbers in cells a1..a10, with formulas that feed off these random numbers in cells b1..b10.

Everytime I "F9" the a1..a10 random numbers regenerate and the formula recalculates values in b1..b10.

What I would like to achieve is to specify a number of simulations, say a maximum of 100 and have the results of these recorded in a separate sheet for each generation.

In other words instead of me pressing F9 100 times and copying and pasting these results can the process be automated - I'd like to record the both the random numbers and results for that selection in the separate sheet.

Thanks!
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

stuartford

Active Member
Joined
Nov 28, 2002
Messages
419
his will add random numbers to cells a1 to a10, then copy the numbers.

the loop goes round 100 times and gives random numbers up to 1000

you just need to out where your going to paste the info to.

im sure theres a better way of writing this code, but hey it works


For a = 1 To 100

Cells(1, 1) = Int((1000 * Rnd))
Cells(1, 2) = Int((1000 * Rnd))
Cells(1, 3) = Int((1000 * Rnd))
Cells(1, 4) = Int((1000 * Rnd))
Cells(1, 5) = Int((1000 * Rnd))
Cells(1, 6) = Int((1000 * Rnd))
Cells(1, 7) = Int((1000 * Rnd))
Cells(1, 8) = Int((1000 * Rnd))
Cells(1, 9) = Int((1000 * Rnd))
Cells(1, 10) = Int((1000 * Rnd))
Range("A1:J1").Copy

Next a

hope it helps Stu
 

gaw1za

New Member
Joined
Dec 20, 2004
Messages
14
Thanks

Is there a way of pasting all the results on to another sheet, e.g. run the simulation 100 times and record each of these in a separate sheet - I see your code lists the numbers in rows which may be easier.
 

Forum statistics

Threads
1,136,263
Messages
5,674,710
Members
419,521
Latest member
Jasonnie

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
Top