I am trying to automate the rows in a solver code that I am writing. Ideally the macro would find the 1st row of data and the last on its own. Right now I have data starting in row 15 and I have calculated the final row as a variable. I want to be able to delete rows in the table of data and have solver automatically adjust the ranges and constraints. any tips/suggestions would be fantastic....
Sub Wealth_Solver2()
finalrow = Cells(Rows.Count, 5).End(xlUp).Row
'target
SolverOk SetCell:="$h$15", MaxMinVal:=1, ByChange:=Range("$i$15:$J$finalrow").Address
'constraints
'> than
SolverAdd CellRef:=Range("$h$15:$H$finalrow").Address, Relation:=3, FormulaText:="0"
SolverAdd CellRef:=Range("$i$15:$J$finalrow").Address, Relation:=3, FormulaText:="0"
SolverAdd CellRef:=Range("$c$15:$d$finalrow").Address, Relation:=3, FormulaText:="0"
SolverAdd CellRef:=Cells(finalrow, 5).Address, Relation:=3, FormulaText:="0"
'< than
SolverAdd CellRef:=Range("$k$15:$k$finalrow").Address, Relation:=1, FormulaText:=Range("$e$15:$e$finalrow")
SolverSolve UserFinish:=False 'true= don;t show result box
End Sub
Bookmarks