Si besoin, voici l'intégralité de mon code :
Sub CalculateEfficientFrontierNOShortsAllowed()
Dim minreturn, maxreturn As Double
Dim i, numsteps As Integer
Dim deltareturn, ret As Double
Dim risk As Double
minreturn = 0#
maxreturn = Range("maxreturn" ).Value
numsteps = 50
deltareturn = (maxreturn - minreturn) / numsteps
ret = 0
SolverReset
SolverOk SetCell:="$H$12", MaxMinVal:=2, ValueOf:=0, ByChange:="$G$4:$G$5", _
Engine:=1, EngineDesc:="GRG Nonlinear"
SolverOptions MaxTime:=100, Iterations:=100, Precision:=0.000001, AssumeLinear:=False, StepThru:=False, Estimates:=1, Derivatives:=1, SearchOption:=1, IntTolerance:=5, Scaling:=False, Convergence:=0.301, AssumeNonNeg:=False
SolverOk SetCell:="$H$12", MaxMinMax:=2, ValueOf:="0", ByChange:="$G$4:$G$6"
SolverAdd CellRef:="$H$9", Relation:=2, FormulaText:="$H$15"
SolverAdd CellRef:="$G$4", Relation:=3, FormulaText:="0"
SolverAdd CellRef:="$G$5", Relation:=3, FormulaText:="0"
SolverAdd CellRef:="$G$6", Relation:=3, FormulaText:="0"
SolverAdd CellRef:="$G$7", Relation:=2, FormulaText:="$H$7"
For i = 1 To numsteps + 1
Range("$H$15" ).Value = ret
SolverSolve True
risk = Sqr(Range("$H$12" ).Value)
Cells(30 + i, 3).Value = risk
Cells(30 + i, 4).Value = ret
ret = ret + deltareturn
Next i
ActiveSheet.Calculate
End Sub