我试图让求解器重复多行数据。到目前为止,这是我的代码。我是新手,这是2行。我希望它一直运行到最后一行。在阅读了类似问题的回答后,我在范围内添加了。
Sub prgopt()
'
' prgopt Macro
'
'
SolverOk SetCell:="$C$2", MaxMinVal:=2, ValueOf:=0, ByChange:="$A$3:$B$3", _
Engine:=1, EngineDesc:=" GRG Nonlinear "
SolverSolve
Range("$C$2").Offset(Count, 0).Select
SolverOk SetCell:="$C$3", MaxMinVal:=2, ValueOf:=0, ByChange:="$A$3:$B$3", _
Engine:=1, EngineDesc:=" GRG Nonlinear "
SolverSolve
End Sub
感谢您的时间和感谢您的帮助 ç
答案 0 :(得分:0)
试试这个:
Sub prgopt()
'
' prgopt Macro
'
'
Dim c As Range
dim nRows as int
nRows = 2
For Each c In Range("$C$2:$C$3")
SolverOk SetCell:=c.Address, MaxMinVal:=2, ValueOf:=0, ByChange:=c.Offset(0, -nRows).Resize(1, nRows), _
Engine:=1, EngineDesc:=" GRG Nonlinear "
SolverSolve userfinish:=True
SolverFinish keepfinal:=1
Next
End Sub
根据需要更改范围和nRows(因子范围的宽度)。希望这会有所帮助。