我正在尝试修改我在一系列单元格上运行Solver的下面脚本。我想要实现的差异:
Sub MacroSolve()
Worksheets("$100 All-In").Activate
RowCount = 3
Do While Not IsEmpty(Worksheets("$100 All-In").Range("A" & RowCount))
SolverReset
SolverOptions precision:=0.000001
SolverOk SetCell:=Range("K" & RowCount), _
MaxMinVal:=3, _
ValueOf:="100", _
ByChange:=Range("C" & RowCount)
SolverSolve userFinish:=True
SolverFinish keepFinal:=1
RowCount = RowCount + 1
Loop
MsgBox "processing over"
End Sub
我录制了这个宏,显示了我在第一行的Solver中所做的事情,但我想对所有单元格进行此操作。
SolverOk SetCell:="$K$3", MaxMinVal:=3, ValueOf:=125#, ByChange:="$C$3,$E$3" _
, Engine:=1, EngineDesc:="GRG Nonlinear"
SolverAdd CellRef:="$C$3", Relation:=2, FormulaText:="$P$3*$G$3"
SolverAdd CellRef:="$E$3", Relation:=2, FormulaText:="$P$4*$G$3"
SolverOk SetCell:="$K$3", MaxMinVal:=3, ValueOf:=125#, ByChange:="$C$3,$E$3" _
, Engine:=1, EngineDesc:="GRG Nonlinear"
SolverOk SetCell:="$K$3", MaxMinVal:=3, ValueOf:=125#, ByChange:="$C$3,$E$3" _
, Engine:=1, EngineDesc:="GRG Nonlinear"
SolverSolve
SolverOk SetCell:="$K$3", MaxMinVal:=3, ValueOf:=125#, ByChange:="$C$3,$E$3" _
, Engine:=1, EngineDesc:="GRG Nonlinear"
End Sub