RiskAMP: Latest News

Using Goalseek

May 27, 2008

When you have a known or desired result in a spreadsheet, but you don’t know the input values, Excel’s built-in Goalseek function can be very helpful in providing or reaching a solution. This can be true in both a flat spreadsheet and in a probability simulation.

The latest version of the RiskAMP Add-in has been updated so it’s now possible to use Goalseek within a simulation. To try it out, you should make sure you have the most recent version of the Add-in installed (version 2.80); you can download updates from our download page.

Using Goalseek within a simulation requires VBA, so you will need to know something about VBA programming. For the most part, this is fairly simple, and actually scripting Goalseek to run is fairly simple if you record a macro.

We’ve posted a very simple example of using Goalseek and a Monte Carlo simulation on our library page:

Excel 2000/2003 Version (.xls)
Excel 2007 Version (.xlsm)

You should download the file that matches your version of Excel.

This spreadsheet runs a Monte Carlo simulation from VBA, and at each iteration it runs Goalseek to solve a simple problem on the spreadsheet. To run the simulation, we use the RiskAMP VBA library (described here). At each iteration, the code runs Goalseek using this code:

Range(”D16″).GoalSeek Goal:=0, ChangingCell:=Range(”C16″)

To figure out that line, we simply recorded a macro and ran Goalseek manually. Using this technique it’s possible to run Goalseek on a spreadsheet and capture the results from a simulation like any other spreadsheet value.