Private Sub ComboBox1_Click()
Dim x, c As Range, sup As Range
If ComboBox1.ListIndex = -1 Then Exit Sub
x = Val(ComboBox1)
With Feuil2 'CodeName de la feuille "Variables"
For Each c In .Range("A1", .Range("A" & .Rows.Count).End(xlUp))
If c = x Then Set sup = Union(c, IIf(sup Is Nothing, c, sup))
Next
End With
sup.EntireRow.Delete
Set sup = Nothing
With Feuil4 'CodeName de la feuille "Feuil1"
For Each c In .Range("A1", .Range("A" & .Rows.Count).End(xlUp))
If c = x Then Set sup = Union(c, IIf(sup Is Nothing, c, sup))
Next
End With
sup.EntireRow.Delete
ComboBox1.RemoveItem ComboBox1.ListIndex
ComboBox1 = "'" & x & "' a été supprimé"
Application.OnTime 1, "DerouleListe" 'macro dans Module3
End Sub
Private Sub UserForm_Initialize()
Dim d1 As Object, d2 As Object, t, i&
Set d1 = CreateObject("Scripting.Dictionary")
Set d2 = CreateObject("Scripting.Dictionary")
t = Feuil2.UsedRange.Resize(, 2) 'au moins 2 éléments
For i = 1 To UBound(t)
If Not IsEmpty(t(i, 1)) Then d1(t(i, 1)) = ""
Next
t = Feuil4.UsedRange.Resize(, 2) 'au moins 2 éléments
For i = 1 To UBound(t)
If d1.exists(t(i, 1)) Then d2(t(i, 1)) = ""
Next
If d2.Count Then ComboBox1.List = d2.keys
Application.OnTime 1, "DerouleListe" 'macro dans Module3
End Sub