View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
tdogg241
 
Posts: n/a
Default Writing a macro that updates solver solutions?

Well, I did some looking around and found out about having Solver open, so I
took care of that. And I also saw the SolverSolve and SolverFinish functions
and added those in an attempt to get it to work properly. So now my code
looks like this:

SolverOk SetCell:="$F$32", MaxMinVal:=3, ValueOf:=100, ByChange:="$A$32"
SolverSolve UserFinish:=True
SolverFinish KeepFinal:=True

It seems to run all the way through to the end, but it doesn't save the
calculations. Also, I don't know whether it matters, but I have 4 statements
like the one above performing SolverOk for different parts of my sheet. I
have also tried inserting a SolverReset line at the beginning, so I have no
idea why it's not working.

"Gary''s Student" wrote:

First make sure that Solver is open. This may require selecting Solver
from the Excel menu and then dismissing the dialog. You'll know Solver is
open when you can see the entry SOLVER (SOLVER.XLA) in the Visual Basic
Editor Project window.

Next, select your workbook's project in the Visual Basic Editor Project
window and choose Tools/References from the menu. Put a check mark beside
the SOLVER reference and click OK. Save your workbook. Your code should work
now.


--
Gary''s Student


"tdogg241" wrote:

I want to write a macro that will update several cells that are calculated
using the solver function. So far, the only way I've found to do this is to
update them one-by-one which is very tedious. So I'm trying to write a macro
that will do this easily. I tried recording the macro and doing it manually,
which gave me the following code:

SolverOk SetCell:="$F$32", MaxMinVal:=3, ValueOf:="100", ByChange:="$A$32"
SolverSolve

Unfortunately, when I try to run the macro, it says that the SolverOk
function is not a valid function. So I'm not sure what I can do to fix this.
Any help is greatly appreciated.