我正在使用Solver模型分发Excel文件。
为了避免某些Excel 2007用户出现引用问题,我没有在VBA编辑器中启用refence,而是按照this post.
中的描述修改语法所以我试图转换此代码:
SolverReset
SolverOptions Precision:=0.001, MultiStart:=True
SolverOk SetCell:="$L$5", MaxMinVal:=2, ValueOf:=0, ByChange:="$J$2:$L$2", _
Engine:=2, EngineDesc:="GRG Nonlinear"
solverAdd cellRef:=Range("$K$2:$L$2"), relation:=1, formulaText:=100
solverAdd cellRef:=Range("$J$2"), relation:=1, formulaText:=2
solverAdd cellRef:=Range("$J$2:$L$2"), relation:=3, formulaText:=0
SolverSolve userFinish:=True, ShowRef:="ShowTrial"
进入这一个:
Application.Run "Solver.xlam!SolverReset"
Application.Run "Solver.xlam!SolverOptions", Precision:=0.001, MultiStart:=True
Application.Run "Solver.xlam!SolverOk", "$L$5", 2, "0", "$J$2:$L$2", _
Engine:=2, EngineDesc:="GRG Nonlinear"
Application.Run "SolverAdd", "$K$2:$L$2", 1, "100"
Application.Run "SolverAdd", "$J$2", 1, "2"
Application.Run "SolverAdd", "$J$2:$L$2", 3, "0"
Application.Run "SolverSolve", True
但是,我在上面的代码第2,第4和第8行中遇到了编译错误。
有人可以帮忙吗?