View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Floyd Bates Floyd Bates is offline
external usenet poster
 
Posts: 1
Default Solver Record Macro Function

All:

I am at a loss on how to use Solver in VBA. I have recorded a macro
based on my Solver requirements. Once I attempt to run this recorded
code, it does nothing.

I have spent hours trying to ensure my references were correct and
that the syntax is correct.

Can someone assist me either via this board or off line.

Running Solver manually works perfectly; however, when I attempt to
automate this it does nothing. There are no error messages and the
target cell never changes. It is as if it is not running at all.

I am assuming there are no issues with the spreadsheet, since Solver
seems to work just fine when initiated manually.

Here is the code:
Sub Macro10()
Dim ShtOb As Object

Worksheets("Pressure Analysis").Activate
Set ShtOb = Worksheets("Pressure Analysis")
SolverReset
SolverOk SetCell:=ShtOb.Cells(54, 15), MaxMinVal:=3,
ValueOf:=4215, ByChange:=ShtOb.Cells(64, 15)
SolverAdd CellRef:=ShtOb.Cells(64, 15), Relation:=1,
FormulaText:=4215
SolverAdd CellRef:=ShtOb.Cells(64, 15), Relation:=3,
FormulaText:=250
SolverOk SetCell:=ShtOb.Cells(54, 15), MaxMinVal:=3,
ValueOf:=4215, ByChange:=ShtOb.Cells(64, 15)
SolverSolve UserFinish:=True
End Sub

Any suggestions would be greatly appreciated.

Thanks in advance.