Ciao e grazie per la risposta Norman.
non le ho sottoposte in quanto ritenevo inutile, visto che il solver mi fornisce la soluzione corretta, comunque eccole:
Sub Risolutore()
Dim answer As Integer
SolverReset
SolverAdd CellRef:="$B$7:$B$11", Relation:=3, FormulaText:="0"
SolverAdd CellRef:="$B$12", Relation:=2, FormulaText:="1"
SolverAdd CellRef:="$B$14", Relation:=2, FormulaText:="$B$2"
SolverOk SetCell:="$B$15", MaxMinVal:=2, ValueOf:=0, ByChange:="$B$7:$B$11", _
Engine:=1, EngineDesc:="GRG Nonlinear"
SolverOk SetCell:="$B$15", MaxMinVal:=2, ValueOf:=0, ByChange:="$B$7:$B$11", _
Engine:=1, EngineDesc:="GRG Nonlinear"
answer = SolverSolve(False, "SolvErr")
'forzando un errore ottengo answer = 9, come detto, ma non viene eseguita la
'Function SolvErr in nessun caso, anche se answer=0 (almeno questo ho capito leggendo qua e là)
End Sub
Function SolvErr(Reason As Integer)
If Reason = 0 Then
MsgBox ("Solver found a solution. All constraints and optimality conditions are satisfied.")
End If
If Reason = 1 Then
MsgBox ("Solver has converged to the current solution. All constraints are satisfied")
End If
If Reason = 2 Then
MsgBox ("Solver cannot improve the current solution. All constraints are satisfied.")
End If
If Reason = 3 Then
MsgBox ("Stop chosen when the maximum iteration limit was reached.")
End If
If Reason = 4 Then
MsgBox ("The Set Cell values do not converge.")
End If
If Reason = 5 Then
MsgBox ("Solver could not find a feasible solution.")
End If
If Reason = 6 Then
MsgBox ("Solver stopped at user's request.")
End If
If Reason = 7 Then
MsgBox ("The conditions for Assume Linear Model are not satisfied.")
End If
If Reason = 8 Then
MsgBox ("The problem is too large for Solver to handle.")
End If
If Reason = 9 Then
MsgBox ("Solver encountered an error value in a target or constraint cell.")
End If
If Reason = 10 Then
MsgBox ("Stop chosen when maximum time limit was reached.")
End If
If Reason = 11 Then
MsgBox ("There is not enough memory available to solve the problem.")
End If
If Reason = 12 Then
MsgBox ("Another Excel instance is using SOLVER.DLL. Try again later.")
End If
If Reason = 13 Then
MsgBox ("Error in model. Please verify that all cells and constraints are valid.")
End If
ShowTrial = True
End Function
Cari saluti