bonsoir,
une solution via des fonctions personnalisées
Function niveaumax(indice, nv, reserve, tableau)
ind = Application.Match(indice, tableau.Columns(1), 0)
colnv = Application.Match("N" & nv, tableau.Rows(1), 0)
For i = colnv + 1 To tableau.Columns.Count
If tableau.Cells(ind, i) > 0 Then
reserve = reserve - tableau.Cells(ind, i)
If reserve < 0 Then niveaumax = tableau.Cells(1, i - 1): Exit Function
Else
niveaumax = tableau.Cells(1, i - 1): Exit Function
End If
Next i
niveaumax = tableau.Cells(1, tableau.Columns.Count)
End Function
Function reservemaxplus1(indice, nv, reserve, tableau)
ind = Application.Match(indice, tableau.Columns(1), 0)
colnv = Application.Match("N" & nv, tableau.Rows(1), 0)
For i = colnv + 1 To tableau.Columns.Count
If tableau.Cells(ind, i) > 0 Then
reserve = reserve - tableau.Cells(ind, i)
If reserve < 0 Then reservemaxplus1 = -reserve: Exit Function
Else
reservemaxplus1 = "niveau max atteint":Exit Function
End If
Next i
reservemaxplus1 = "niveau max atteint"
End Function