24-01-2012, 10:34 AM
bonjour, j'ai besoin d'aide, cela fait deux semaine que je crèche sur mon problème que voici. j'ai fais une macro qui utilise le solver d'excel via VB. Apparemment le code semble bon mais lorsque je lance la compilation, on me dis une erreur est survenue ou la mémoire disponible est saturée, svp chers amis programmeurs j'ai besoin d'aide.
Voici le code
Private Sub CommandButton1_Click()
'SolverReset
SolverOptions MaxTime:=100, Iterations:=100, Precision:=0.000001, Estimates:=1, SearchOption:=1, IntTolerance:=5, Convergence:=0.0001
SolverOk SetCell:="C12", MaxMinVal:=3, ValueOf:=Sheets("RNA").Range("F12"), ByChange:="RNA!$ C $ 2: $ C $ 11"
SolverAdd CellRef:="RNA!C2", Relation:=1, FormulaText:=Sheets("RNA").Range("E2")
SolverAdd CellRef:="RNA!C2", Relation:=3, FormulaText:=Sheets("RNA").Range("F2")
SolverAdd CellRef:="RNA!C3", Relation:=1, FormulaText:=Sheets("RNA").Range("E3")
SolverAdd CellRef:="RNA!C3", Relation:=3, FormulaText:=Sheets("RNA").Range("F3")
SolverAdd CellRef:="RNA!C4", Relation:=1, FormulaText:=Sheets("RNA").Range("E4")
SolverAdd CellRef:="RNA!C4", Relation:=3, FormulaText:=Sheets("RNA").Range("F4")
SolverAdd CellRef:="RNA!C5", Relation:=1, FormulaText:=Sheets("RNA").Range("E5")
SolverAdd CellRef:="RNA!C5", Relation:=3, FormulaText:=Sheets("RNA").Range("F5")
SolverAdd CellRef:="RNA!C6", Relation:=1, FormulaText:=Sheets("RNA").Range("E6")
SolverAdd CellRef:="RNA!C6", Relation:=3, FormulaText:=Sheets("RNA").Range("F6")
SolverAdd CellRef:="RNA!C7", Relation:=1, FormulaText:=Sheets("RNA").Range("E7")
SolverAdd CellRef:="RNA!C7", Relation:=3, FormulaText:=Sheets("RNA").Range("F7")
SolverAdd CellRef:="RNA!C8", Relation:=1, FormulaText:=Sheets("RNA").Range("E8")
SolverAdd CellRef:="RNA!C8", Relation:=3, FormulaText:=Sheets("RNA").Range("F8")
SolverAdd CellRef:="RNA!C9", Relation:=2, FormulaText:=Sheets("RNA").Range("E9")
SolverAdd CellRef:="RNA!C10", Relation:=1, FormulaText:=Sheets("RNA").Range("E10")
SolverAdd CellRef:="RNA!C10", Relation:=3, FormulaText:=Sheets("RNA").Range("F10")
SolverAdd CellRef:="RNA!C11", Relation:=1, FormulaText:=Sheets("RNA").Range("E11")
SolverAdd CellRef:="RNA!C11", Relation:=3, FormulaText:=Sheets("RNA").Range("F11")
SolverOk SetCell:="C12", MaxMinVal:=3, ValueOf:=Sheets("RNA").Range("E12"), ByChange:="RNA!$ C $ 2: $ C $ 11"
SolverSolve UserFinish:=False
SolverFinish KeepFinal:=1, ReportArray:=(1)
End Sub
Voici le code
Private Sub CommandButton1_Click()
'SolverReset
SolverOptions MaxTime:=100, Iterations:=100, Precision:=0.000001, Estimates:=1, SearchOption:=1, IntTolerance:=5, Convergence:=0.0001
SolverOk SetCell:="C12", MaxMinVal:=3, ValueOf:=Sheets("RNA").Range("F12"), ByChange:="RNA!$ C $ 2: $ C $ 11"
SolverAdd CellRef:="RNA!C2", Relation:=1, FormulaText:=Sheets("RNA").Range("E2")
SolverAdd CellRef:="RNA!C2", Relation:=3, FormulaText:=Sheets("RNA").Range("F2")
SolverAdd CellRef:="RNA!C3", Relation:=1, FormulaText:=Sheets("RNA").Range("E3")
SolverAdd CellRef:="RNA!C3", Relation:=3, FormulaText:=Sheets("RNA").Range("F3")
SolverAdd CellRef:="RNA!C4", Relation:=1, FormulaText:=Sheets("RNA").Range("E4")
SolverAdd CellRef:="RNA!C4", Relation:=3, FormulaText:=Sheets("RNA").Range("F4")
SolverAdd CellRef:="RNA!C5", Relation:=1, FormulaText:=Sheets("RNA").Range("E5")
SolverAdd CellRef:="RNA!C5", Relation:=3, FormulaText:=Sheets("RNA").Range("F5")
SolverAdd CellRef:="RNA!C6", Relation:=1, FormulaText:=Sheets("RNA").Range("E6")
SolverAdd CellRef:="RNA!C6", Relation:=3, FormulaText:=Sheets("RNA").Range("F6")
SolverAdd CellRef:="RNA!C7", Relation:=1, FormulaText:=Sheets("RNA").Range("E7")
SolverAdd CellRef:="RNA!C7", Relation:=3, FormulaText:=Sheets("RNA").Range("F7")
SolverAdd CellRef:="RNA!C8", Relation:=1, FormulaText:=Sheets("RNA").Range("E8")
SolverAdd CellRef:="RNA!C8", Relation:=3, FormulaText:=Sheets("RNA").Range("F8")
SolverAdd CellRef:="RNA!C9", Relation:=2, FormulaText:=Sheets("RNA").Range("E9")
SolverAdd CellRef:="RNA!C10", Relation:=1, FormulaText:=Sheets("RNA").Range("E10")
SolverAdd CellRef:="RNA!C10", Relation:=3, FormulaText:=Sheets("RNA").Range("F10")
SolverAdd CellRef:="RNA!C11", Relation:=1, FormulaText:=Sheets("RNA").Range("E11")
SolverAdd CellRef:="RNA!C11", Relation:=3, FormulaText:=Sheets("RNA").Range("F11")
SolverOk SetCell:="C12", MaxMinVal:=3, ValueOf:=Sheets("RNA").Range("E12"), ByChange:="RNA!$ C $ 2: $ C $ 11"
SolverSolve UserFinish:=False
SolverFinish KeepFinal:=1, ReportArray:=(1)
End Sub