Problem: I get sometimes funny error messages in VBA (Excel) that VBA can't execute a simple command such as Cells(1,1).select when adding code to my existing script. I don't think that the error message is pointing in the right direction because there is nothing wrong with the above descript command and this command was previously executed before adding more code to my existing script.
I am using the solver add in my program and I was wondering if that will use up a lot of memory and I want to make sure that I release the memory properly. The solver is called several 1000 times in this routine and it could possibly produce a big mess if it does release the memory correctly. Which in turn the throws up error messages that VBA can't execute the above mentioned Cells(1,1).select command.
Code example
'Open solver library
Application.Run "Solver.xla!Aut
pen"
'Clear solver contraints
SOLVERReset
For i=1 to 100
'Set solver contraints
SolverAdd CellRef:="$H$114", Relation:=1, FormulaText:="$H$103"
SolverAdd CellRef:="$H$119", Relation:=3, FormulaText:="$H$103"
'Call solver and calculate result
SolverOk SetCell:="$H$101", MaxMinVal:=2, ValueOf:="0", ByChange:="$H$103"
SolverSolve UserFinish:=True
SolverFinish KeepFinal:=1
'reset solver after the job is done
SOLVERReset
NEXT
' close solver library
Application.Run "Solver.xla!Auto_Close"
I am using the solver add in my program and I was wondering if that will use up a lot of memory and I want to make sure that I release the memory properly. The solver is called several 1000 times in this routine and it could possibly produce a big mess if it does release the memory correctly. Which in turn the throws up error messages that VBA can't execute the above mentioned Cells(1,1).select command.
Code example
'Open solver library
Application.Run "Solver.xla!Aut
'Clear solver contraints
SOLVERReset
For i=1 to 100
'Set solver contraints
SolverAdd CellRef:="$H$114", Relation:=1, FormulaText:="$H$103"
SolverAdd CellRef:="$H$119", Relation:=3, FormulaText:="$H$103"
'Call solver and calculate result
SolverOk SetCell:="$H$101", MaxMinVal:=2, ValueOf:="0", ByChange:="$H$103"
SolverSolve UserFinish:=True
SolverFinish KeepFinal:=1
'reset solver after the job is done
SOLVERReset
NEXT
' close solver library
Application.Run "Solver.xla!Auto_Close"