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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
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
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,213,506
Messages
6,114,024
Members
448,543
Latest member
MartinLarkin

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