View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jon Peltier Jon Peltier is offline
external usenet poster
 
Posts: 6,582
Default VBA code to RUN Solver mutiple times (on different target cells)

Not tested, but this should get you started:

Dim iRow As Long, iCol As Long
Dim sSetCell As String, sByChange As String
For iRow = 52 To 152 ' guessing the range
For iCol = 6 to 11 ' columns F through K
sSetCell = Range("A1").Offset(iRow - 1, iCol - 1).Address
sByChange = Range("A1").Offset(iRow - 1, 2).Address
SolverOk SetCell:=sSetCell, MaxMinVal:=3, ValueOf:="0",
ByChange:=sByChange
SolverAdd CellRef:=sByChange, Relation:=3, FormulaText:="0"
SolverSolve True
Next
Next

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services, Inc.
http://PeltierTech.com/WordPress/
_______


"BEETAL" wrote in message
...
Can some one help to modefy the following code wherein I can run
the macro on 250 cells across a table/or matrix form.


SolverOk SetCell:="$F$52", MaxMinVal:=3, ValueOf:="0",_ ByChange:="$C$52"
SolverAdd CellRef:="$C$52", Relation:=3, FormulaText:="0"
SolverSolve True
SolverOk SetCell:="$F$53", MaxMinVal:=3, ValueOf:="0",_ ByChange:="$C$53"
SolverAdd CellRef:="$C$53", Relation:=3, FormulaText:="0"
SolverSolve True

end sub
I need to run the solver on coloumns f to k on 20 cells each. Can I use a
range command or offset command
to keep changing the target cells over and over.

Some loop structure would do ,I suppose. Since I have never worked
on this before, I would like a jum- start on solver.

The constraints will be set as shown.

thank you very much for the timely help, in advance.
--
beetal