Tania Smolianinowa
Tania Smolianinowa

Reputation: 5

Applying Solver to multiple

I'm new to VBA, trying to apply Solver to multiple cells. But I get an error: Sub or Function not defined.

Here is the code:

  Sub SolverRepeat()
Dim i As Integer
For i = 4 To 8763
    SolverReset
        SolverOk SetCell:="$BQ$" & i, MaxMinVal:=2, ValueOf:="0", ByChange:="$BI$" & i, Engine:=1, EngineDesc:="GRG Nonlinear"
    SolverSolve True
    Next i
End Sub

Upvotes: 0

Views: 724

Answers (1)

Rik Sportel
Rik Sportel

Reputation: 2679

Most likely you have not added the reference to your VBA project.

To do this: In the Visual Basic Editor, with a module active, click References on the Tools menu, and then select Solver under Available References. If Solver does not appear under Available References, click Browse, and then open Solver.xlam in the \Program Files\Microsoft Office\Office14\Library\SOLVER subfolder.

Source: Using the Solver VBA Functions

Upvotes: 1

Related Questions