Function prix(cel As Range) ' cel étant la quantité réelle
For i = (Asc("J") - 64) To Cells(cel.Row, Columns.Count).End(xlToLeft).Column Step 3
If Cells(cel.Row, i) > cel Or Cells(cel.Row, i) = "" Then Exit For
prix = Cells(cel.Row, i + 1)
Next
End Function
Function optimum(cel As Range) ' cel étant la quantité réelle
For i = (Asc("J") - 64) To Cells(cel.Row, Columns.Count).End(xlToLeft).Column Step 3
If Cells(cel.Row, i + 2) < cel.Offset(0, 2) And Cells(cel.Row, i + 2) <> 0 Then optimum = Cells(cel.Row, i)
Next
optimum = Application.Max(optimum, cel.Value)
End Function