【发布时间】:2014-04-30 22:50:52
【问题描述】:
我正在尝试使用求解器编写循环。
Sub SharpeRatio()
SolverReset
SolverOk SetCell:="$Q$18", MaxMinVal:=1, ValueOf:="0", ByChange:="$L$18,$M$18", Engine:=1, EngineDesc:="GRG Nonlinear"
SolverAdd CellRef:="$L$18", Relation:=3, FormulaText:="0"
SolverAdd CellRef:="$L$18", Relation:=1, FormulaText:="1"
SolverAdd CellRef:="$M$18", Relation:=3, FormulaText:="0"
SolverAdd CellRef:="$M$18", Relation:=1, FormulaText:="1"
SolverAdd CellRef:="$R$18", Relation:=2, FormulaText:="1"
SolverSolve UserFinish:=True
End Sub
求解器代码有效。我需要优化列 Q 中的所有单元格,同时使用每一行中值的约束。我需要对第 14 到 2843 行执行此操作。
我似乎无法进入正确的循环。我应该如何重写这个?
【问题讨论】: