Hi,
No problem - we like to get this stuff in the forum in the event that it can help other people, so I'm happy to help. Let me answer some of this in turn:
> I am calling my 'uprotect' routine on sheet activate
> and then running RiskAmp from the toolbar. So I would
> have to assume that my sheet is unprotected before I
> run the RiskAmp Simulation but still get the error message.
This really depends on when the sheet gets activated (and the routine is run). It's likely that in your case it's not happening in the right order. You could probably figure out a way to make it work, but it's really wiser to use VBA here.
> If I were to run the RiskAmp Simulation from VB I would want
> to allow the user to choose how many trials they want to run.
You can do this, it's a little more complicated than your example. You have to get the number of trials as a number (not a cell name), but this is easy; in VBA, you can use something like
numberOfTrials = Range( "A1" ).value
which will get the value out of A1. It would be a good idea to check that it's a valid number, too.
> I would also like to let the user choose whether to show the
> simulation or not show the simulation.
You can do this the same way; the "run simulation" function which you call from vba takes a second parameter, which controls whether to hide updates. So if you wanted to run a simulation but show the updates, you would call something like
Application.ExecuteExcel4Macro ("RiskAMP_RunSimulation( 1000, FALSE )")
I've put together a simple example that ties all this together. You should be able to use it almost as-is, just changing the names of the various cells and sheets. Basically, when you click the button it
(1) gets the number of trials, from a cell
(2) gets whether to show screen updates, from another cell
(3) unprotects worksheets
(4) runs a simulation
(5) re-protects worksheets.
It's at [
www.riskamp.com]. Let me know if this works for you.
Cheers,
Alex