0

When I am running the below code the error "Name argument not found" is coming for SetCell:="$I$3".

Sub Simple_Exponential_Smoothing()
    Dim x As Integer
    Dim lastrow As Integer
    Application.ScreenUpdating = False
    Sheets("COV_0.2").Cells(1, 49).Value = "MAD"
    Sheets("COV_0.2").Cells(1, 50).Value = "Alpha"
    lastrow = Sheets("COV_0.2").Cells(Rows.Count, 2).End(xlUp).Row
    For x = 2 To lastrow
        If Sheets("COV_0.2").Cells(x, 31).Value <> "S4" Then
            Range("G" & x & ":AD" & x).Select
            Selection.Copy
            Sheets("Analysis_Constant").Select
            Range("C4").Select
            Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, _
                SkipBlanks:=False, Transpose:=True
            Application.Run "Solver.xlam!SolverReset"

   '***ERROR ON THE FOLLOWING LINE: `Name argument not found`
            Application.Run "Solver.xlam!SolverOk", SetCell:="$I$3", _
                MaxMinVal:=2, ValueOf:=0, ByChange:="$G$1", Engine:=3, _
                EngineDesc:="Evolutionary"

            Application.Run "Solver.xlam!SolverAdd", CellRef:="$G$1", _
                Relation:=1, FormulaText:="0.9"
            Application.Run "Solver.xlam!SolverAdd", CellRef:="$G$1", _
                Relation:=3, FormulaText:="0.1"
            SolverSolve True
Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73

1 Answers1

0

You must set a reference to the Solver addin in Tools/References:

  1. Select References from the Tools menu in the Excel VBA editor window.
  2. Check the "Solver" checkbox.
  3. Click OK.

And then the correct Solver syntax would be:

SolverReset

SolverOk SetCell:="$I$3", _
    MaxMinVal:=2, ValueOf:=0, ByChange:="$G$1", Engine:=3, _
    EngineDesc:="Evolutionary"

SolverAdd CellRef:="$G$1", Relation:=1, FormulaText:="0.9"
SolverAdd CellRef:="$G$1", Relation:=3, FormulaText:="0.1"
SolverSolve True

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73