Any help on this would be GREATLY appreciated. I am trying to have a solver program solve problems based on certain constraints placed on the cells. This is the code that has been generated:
-----------------------------------------------------------------------
Sub Format_Solver_DRP()
' Format_Solver_DRP Macro
' Macro recorded 09/14/2006 by Lynn Holt
Dim row_num As Double
'Set row_num to starting row in worksheet
row_num = 2
SOLVER.Auto_open
Do
'SOLVER.SolverReset
'Run solver for each row independently
'Check to see if row/cell in B column has a value or not
If Range("B" & row_num).Value = "" Then
Else
Worksheets("Sheet2").Activate
'Clear solver parameters
'Set parameters
SolverOk SetCell:=Range("P" & row_num).Address, MaxMinVal:=2, ValueOf:="0", ByChange:=Range("F" & row_num, "G" & row_num).Address
'Set constraints
SolverChange CellRef:=Range("F" & row_num).Value, Relation:=4, FormulaText:="integer"
SolverChange CellRef:=Range("G" & row_num).Value, Relation:=4, FormulaText:="integer"
SolverChange CellRef:=Range("M" & row_num).Value, Relation:=2, FormulaText:=Range("N" & row_num).Value
SolverChange CellRef:=Range("G" & row_num).Value, Relation:=3, FormulaText:="0"
SolverChange CellRef:=Range("F" & row_num).Value, Relation:=3, FormulaText:="0"
SolverOk SetCell:=Range("P" & row_num).Value, MaxMinVal:=2, ValueOf:="0", ByChange:=Range("F" & row_num, "G" & row_num).Address
'SOLVER.SolverSave
'Run solver
SolverSolve UserFinish:=True
'Keep results
'SOLVER.SolverFinish KeepFinal:=1
row_num = row_num + 1
End If
'Increase row number by 1
'Break loop if row/cell is null or blank
Loop Until Range("B" & row_num).Value = ""
Dim exit_loop As Boolean
-----------------------------------------------------------------------
The problem is, the first row (f2 and g2) will run correctly, but the following rows don't seem to follow the same constraints. The other odd thing, is if you start the macro at the f3 and g3, it will work for that row, but not the rows that follow. Is there something wrong with the code that isn't allowing the constraints to follow the cells? Please help!
Bookmarks