Function SemaineRupture(PlageSemaine As Range, PlageStock As Range, QtéRupture As Integer) As String
Dim c As Range
Dim i As Integer
Dim bValid As Boolean
If PlageSemaine.Rows.Count <> 1 Then Exit Function
If PlageStock.Rows.Count <> 1 Then Exit Function
If PlageSemaine.Columns.Count <> PlageStock.Columns.Count Then Exit Function
bValid = False
i = 1
For Each c In PlageStock
If c <> 0 Then bValid = True
If c <= QtéRupture And bValid Then
SemaineRupture = WorksheetFunction.Index(PlageSemaine, i)
Exit Function
End If
i = i + 1
Next c
SemaineRupture = "Pas de rupture"
End Function