# Simulations

#### gaw1za

##### New Member
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

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

#### stuartford

##### Active Member
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
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.

Replies
0
Views
95
Replies
8
Views
390
Replies
0
Views
218
Replies
1
Views
412
Replies
4
Views
457

1,171,253
Messages
5,874,677
Members
433,065
Latest member
Leo55

### 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.

### Which adblocker are you using?

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

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