I am running a macro in Excel 2013 that uses Solver for each row (one account per row) for 30 rows.
I have two constraints:
*Note that H = C-sum(I,J) so it's not an independent variable.
Question 1. for the first constraint: I have in my code:
SolverAdd CellRef:=Range("I" & RowCount), _
Relation:=3, _
FormulaText:=Range("J" & RowCount)
*Note that I tried googling formulaText but it seems that the ones I found only equate it to a value. I don't want a value. I want it to reference a cell. but the code I have kept getting ignored. the results would show J being greater than I. How do I solve this?
Question 2. I keep getting error when running
SolverAdd CellRef:=Range("H" & RowCount), _
Relation:=3, _
FormulaText:=Range("I" & RowCount)
I'm not sure why it would fail. Is it because H is referring an equation instead of a blank cell? If so, is there any way around it?
Thank you.
have you got any further with this?
this seemed to work ok for me, though I had a hardcoded value in H
SolverReset
SolverOk SetCell:="$L$3", MaxMinVal:=3, ValueOf:=0, ByChange:="$I$3:$J$3", _
Engine:=1, EngineDesc:="GRG Nonlinear"
SolverAdd CellRef:="$H$3", Relation:=3, FormulaText:="$I$3"
SolverAdd CellRef:="$I$3", Relation:=3, FormulaText:="$J$3"
SolverSolve
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.