macro solveur en visual basic
Merci ! ça marche.
J'ai un nouveau petit problème. Quand je clique la première fois sur mon bouton relié à cette macro, il s'arrête après la définition de la plage des cellules variables (ByChange:=Criteria). Quand je reclique, il va au bout de la macro. Pourquoi ?
PrivateSub CommandButton1_Click()
Worksheets('').Activate
SolverReset
i = 22
If IsEmpty(Range('A22')) Then
i = i - 1
If IsEmpty(Range('A21')) Then
i = i - 1
If IsEmpty(Range('A20')) Then
i = i - 1
If IsEmpty(Range('A19')) Then
i = i - 1
If IsEmpty(Range('A18')) Then
i = i - 1
If IsEmpty(Range('A17')) Then
i = i - 1
If IsEmpty(Range('A16')) Then
i = i - 1
End If
End If
End If
End If
End If
End If
End if
Criteria = 'C15:C' & i
SolverOptions
SolverOK SetCell:=Range('C23')
MaxMinVal:=1,_
ByChange:=Criteria
SolverAdd Cellref:=Range('D24'),_
Relation:=2,_
FormulaText:='$D$23'
SolverSolve UserFinish:=False
SolverSave SaveArea:=Range('L1')
End Sub
Merci d'avance.