close

I am running multiple Marte Carlo simulations involving 300 iterations per
run. I want to automatically record the data from each run so that I can
build a better data base.

Hi,

the following macro assumes that your system will run a new simulation
using the F9 key, i.e. simple calculation. It writes to a destination
worksheet named Target Sheet. It stores 10 output cells, starting with
B4 and G2 and ends with X3.

It provides for up to 65535 simulations. You can start from row 1 if
you don't need headers. The code can be changed with a loop in its
core, if output data is a table. It can be modified to much more rows,
or you might find an already made variant for Access or some DBMS in
..programming.

Sub SimAndStore()
Dim dest As Worksheet
Dim i As Long
Dim destcell As Range

Set dest = Sheets(quot;Target Sheetquot;)
Application.Calculation = xlCalculationManual
For i = 2 To 65536
Application.Calculate
Set destcell = dest.Cells(i, 1)
destcell.Cells(1, 1) = Range(quot;B4quot;)
destcell.Cells(1, 2) = Range(quot;G2quot;)
'...
destcell.Cells(1, 10) = Range(quot;X3quot;)
Next i
Application.Calculation = xlCalculationAutomatic
End Sub

HTH
Kostis VezeridesLaStormPrep -

gt; I am running multiple Marte Carlo simulations involving 300 iterations per
gt; run. I want to automatically record the data from each run so that I can
gt; build a better data base. lt;

Assuming you have a model with random inputs and a single output, one method
is to use the Data Table command: a column of quot;trialquot; numbers, 1 to 300; a
formula at the top of an adjacent column on the right, usually just a
reference to the cell containing the output formula of your model; select
both columns, including the blank cell at the top of the column on the left,
and enter any unused cell as the quot;Column Input Cellquot; in the Data Table
dialog box.

- Mike
www.mikemiddleton.com

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()