Greetings!
Im trying to run a solver loop that will loop through and optimize for the highest return possible on a yearly basis.
See image. What I want to do is use the previous years returns across the 7 asset classes shown to optimize the weights invested the following year in the hopes that this will provide favorable data to just simple equal weighting year after year.
The core of what I want to loop is below.
I4 is the starting value id like to optimize and then Id like to take the value in I5 and copy and paste the value alone into I5
I'd like the loop to then go to I5 and optimize based on the same constraints below and then copy and the values of I6 into I6...and so on until the referenced cell contains no value.
I cant quite figure out how to get the loop to work so im simply posting the optimizer code I know will work...
Let me know if further clarification is needed.
Im trying to run a solver loop that will loop through and optimize for the highest return possible on a yearly basis.
See image. What I want to do is use the previous years returns across the 7 asset classes shown to optimize the weights invested the following year in the hopes that this will provide favorable data to just simple equal weighting year after year.
The core of what I want to loop is below.
I4 is the starting value id like to optimize and then Id like to take the value in I5 and copy and paste the value alone into I5
I'd like the loop to then go to I5 and optimize based on the same constraints below and then copy and the values of I6 into I6...and so on until the referenced cell contains no value.
I cant quite figure out how to get the loop to work so im simply posting the optimizer code I know will work...
VBA Code:
Sub Solver_Final()
'
' Solver_Final Macro
'
' Keyboard Shortcut: Ctrl+Shift+O
'
SolverReset
SolverAdd CellRef:="$I$1", Relation:=2, FormulaText:="1"
SolverAdd CellRef:="$B$1:$H$1", Relation:=3, FormulaText:=".1"
SolverOk SetCell:="[COLOR=rgb(97, 189, 109)][B]I4[/B][/COLOR]", MaxMinVal:=1, ValueOf:=0, ByChange:="$B$1:$H$1", _
Engine:=1, EngineDesc:="GRG Nonlinear"
SolverSolve True
End Sub
Let me know if further clarification is needed.