Private Sub ComboBox1_Change()
Me.ComboBox2.Clear
With Sheets("Données")
lig = Application.Match(Me.ComboBox1, .Range("B1:B" & .[B65000].End(xlUp).Row), 0) + 1
derli = .Cells(lig, 1).End(xlDown).Row
For Each cel In .Range(.Cells(lig, 2), .Cells(derli, 2))
Me.ComboBox2.AddItem cel.Value
Next cel
End With
End Sub
Private Sub ComboBox2_Change()
Me.TextBox1.Value = ""
If Me.ComboBox2 = "" Then Exit Sub
With Sheets("Données")
lig = Application.Match(Me.ComboBox2, .Range("B1:B" & .[B65000].End(xlUp).Row), 0)
Me.TextBox1.Value = .Cells(lig, 1).Value
End With
End Sub
Private Sub CommandButton1_Click()
With Sheets("Userform")
If Me.ComboBox2 = "" Then Exit Sub
derli = .[A65000].End(xlUp).Row + 1
.Cells(derli, 1).Value = Me.TextBox1
.Cells(derli, 2).Value = Me.ComboBox2
End With
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
With Sheets("Données")
For Each cel In .Range("A1:A" & .[B65000].End(xlUp).Row).SpecialCells(xlCellTypeBlanks)
Me.ComboBox1.AddItem cel.Offset(0, 1).Value
Next cel
End With
End Sub