I have created the following macro, which loops through a set of rows optimising product price for every row.
Sub OptimizePrice()
Dim i As Integer
ActiveWorkbook.ActiveSheet.Activate
For i = 5 To 20
SolverReset
SolverOk SetCell:="$K$" & i, MaxMinVal:=1, ByChange:="$B$" & i, Engine:=1
SolverAdd CellRef:="$B$" & i, Relation:=1, FormulaText:="$E$" & i
SolverAdd CellRef:="$F$" & i, Relation:=1, FormulaText:="$G$" & i
SolverSolve True
Range("$L$" & i)= SolverSolve Return Value
Next i
End Sub
Sometimes Solver finds an optimal solution, sometimes it doesn't. I want my macro to PASTE for every row in column "L", the result of the operation, which ranges from 0 to 20 according to the description provided in the following webpage: https://www.solver.com/excel-solver-solversolve-function.
I've tried to achieve this with this line of code 'Range("$L$" & i)= SolverSolve Return Value' but it seems it's not the right way to get the returnvalue type.
Your help is appreciated!.
Range("$L$" & i)= SolverSolve Return Value->Cells(i, "L").Value = SolverSolve- WizhiActiveWorkbook.ActiveSheet.Activate. Happy coding :)!! - Wizhi