Palisade Knowledge Base

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 workbooks show one way to do this. There are two workbooks, one for @RISK 4.x and one for 7.x.  (You can adapt the 7.x workbook to 6.x by changing the references.) 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 property for running a macro after iteration recalc to True.
    2. Store 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 VBA method to start the simulation.

You can either run the simulation by clicking View » Macros » View Macros » macroname » Run (in Excel 2003 and 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: 2018-01-23


This page was: Helpful | Not Helpful