Question

I´m a beginner at VBA programming and I´m having some difficulties regarding Excel Add-in. I wrote a macro that helps to solve some problems I have in my work using Solver. In my machine it works perfectly, however when I try to share to other computers it ends up closing excel. The error that shows up refers to the use of solver. Does anyone knows how to work around that? What I thought I needed to do was to send the worksheet and the add-in, but that hasn´t been enough for now. Thanks for the help, below is my code for the add-in.

Sub Teste2()
'
' Teste2 Macro
'

'
SolverReset
SolverOk SetCell:="$K$11", MaxMinVal:=3, ValueOf:=Range("B3").Value2, ByChange:="$B$8:$E$8", _
    Engine:=1, EngineDesc:="GRG Nonlinear"
SolverAdd CellRef:="$B$8", Relation:=1, FormulaText:="$B$8"
SolverAdd CellRef:="$B$8", Relation:=2, FormulaText:="$K$7"
SolverAdd CellRef:="$C$8", Relation:=1, FormulaText:="$C$8"
SolverAdd CellRef:="$C$8", Relation:=2, FormulaText:="$L$7"
SolverAdd CellRef:="$D$8", Relation:=1, FormulaText:="$D$8"
SolverAdd CellRef:="$D$8", Relation:=3, FormulaText:="$M$7"
SolverAdd CellRef:="$E$8", Relation:=1, FormulaText:="$E$8"
SolverAdd CellRef:="$E$8", Relation:=3, FormulaText:="$N$7"
SolverAdd CellRef:="$K$9", Relation:=1, FormulaText:="$L$9"
SolverSolve UserFinish:=True
SolverFinish KeepFinal:=1
End Sub

Correction:

When I try to run the add-in in another computer, it returns that it cannot find the object and then it shuts down.

Was it helpful?

Solution

Kindly ensure that the other user has enabled reference to "Solver" in the VBE:

enter image description here

Google turned this up as the first result for "Excel Solver macro error":

http://peltiertech.com/Excel/SolverVBA.html

This resource also contains other information that might be helpful for you while working with the Solver model in Excel VBA.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top