Looping solver function in VBA

adustin42

New Member
Joined
Dec 2, 2020
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
I am trying to loop a solver function to minimize RMSE in excel by altering the alpha, beta and gamma values of a holts winter forecast for over 300 line items. For efficiency and testing the loop is only using row 8 to 12 for the time being. When I run it, it processes for a second, but no change after that. Please advise.

1606949124480.png


Code:
 

Some videos you may like

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

adustin42

New Member
Joined
Dec 2, 2020
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
VBA Code:
Sub Macro3()
'
' Macro3 Macro
'
Dim i As Integer
ActiveWorkbook.ActiveSheet.Activate
For i = 8 To 12
SolverReset

    SolverOk SetCell:="$J$" & i, MaxMinVal:=2, ValueOf:=0, ByChange:="$G & i : $I &i", _
        Engine:=1, EngineDesc:="GRG Nonlinear"
    SolverAdd CellRef:="$G:$I", Relation:=1, FormulaText:="1"
    SolverAdd CellRef:="$G:$I", Relation:=3, FormulaText:="0"
    SolverOk SetCell:="$J$" & i, MaxMinVal:=2, ValueOf:=0, ByChange:="$G & i : $I &i", _
        Engine:=1, EngineDesc:="GRG Nonlinear"
    SolverOk SetCell:="$J$" & i, MaxMinVal:=2, ValueOf:=0, ByChange:="$G & i : $I &i", _
        Engine:=1, EngineDesc:="GRG Nonlinear"
        
    SolverSolve True
    Next i
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,127,898
Messages
5,627,530
Members
416,250
Latest member
darius_rebelo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top