Bonjour,
essaie avec ce code dans l'évènement de feuille (Feuil4)
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cel As Range
Dim Fournisseurs As Object
If Target.Count > 1 Then Exit Sub
If Target.Address = "$A$2" And Target <> "" Then
Set Fournisseurs = CreateObject("Scripting.Dictionary")
With Sheets(CStr(Target))
For Each Cel In .Range("B2:B" & .[B65000].End(xlUp).Row)
Fournisseurs.Item(Cel.Value) = Cel.Value
Next Cel
End With
temp = Fournisseurs.items
Call tri(temp, LBound(temp), UBound(temp))
For i = LBound(temp) To UBound(temp)
tmp = tmp & "," & temp(i)
Next i
tmp = Right(tmp, Len(tmp) - 1)
With Target.Offset(, 1)
.ClearContents
.Validation.Delete
.Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=tmp
.Select
End With
End If
End Sub
Sub tri(a, gauc, droi) ' Quick sort
ref = a((gauc + droi) \ 2)
g = gauc: d = droi
Do
Do While a(g) < ref: g = g + 1: Loop
Do While ref < a(d): d = d - 1: Loop
If g <= d Then
temp = a(g): a(g) = a(d): a(d) = temp
g = g + 1: d = d - 1
End If
Loop While g <= d
If g < droi Then Call tri(a, g, droi)
If gauc < d Then Call tri(a, gauc, d)
End Sub
https://www.excel-pratique.com/~files/doc2/Suivi_Commande_v1.zip