HomeTechniques and Tips@RISK Simulation: Numerical ResultsExporting Information During Simulation

6.17. Exporting Information During Simulation

Applies to:
@RISK for Excel 4.x–7.x
RISKOptimizer 1.x, 5.x

While the simulation is running, how can I store intermediate results outside the Excel workbook?

All editions of @RISK offer the ability to run a user-written macro after every iteration. The Professional and Industrial editions of @RISK include the Excel Developer Kit (XDK), a complete library of commands and functions that let you control every aspect of @RISK in your spreadsheet.

You can export data to a text file during simulation by using a VBA macro. The attached sample workbook shows one way to do this. Caution: In Excel 2007 and later, watch for a security warning when you open this workbook, and enable the macros.

To create a custom macro, use the @RISK VBA functions listed in the online manual. Check the @RISK Help File when @RISK is running, or click Windows Start » Programs » Palisade » Online Manuals » @RISK Macros. (In @RISK 5.5.1 and later, run @RISK and select @RISK's help, then Developer Kit.)

Performing a simulation that executes a macro after the recalculation of each iteration requires two steps:

  1. Create a new macro that writes the desired information to a numbered text file. In our example, this macro is named WriteToTxtFile( ).

  2. Create a main macro that sets the simulation settings and runs the simulation. In this macro you must:

    1. Set the RunAfterRecalcMacro property to True.
    2. Set the AfterRecalcMacro property to the name of the macro you created in step 1 above.
    3. Open the text file where your simulation data will be written.
    4. Execute the RiskSimulate command to run the simulation.

You can either run the simulation by clicking View » Macros » View Macros » macroname » Run (in Excel 2003 an earlier, Tools » Macro » Macros » macroname » Run), or create a button as in the example, so that the macro runs when you click the button.

Last edited: 2015-06-30


This page was: Helpful | Not Helpful