1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| Dim choix1()
Private Sub UserForm_Initialize()
choix1 = [villes].Value
cp = [cp].Value
Me.ComboBox1.List = choix1
End Sub
Private Sub ComboBox1_Change()
If Me.ComboBox1.ListIndex = -1 And IsError(Application.Match(Me.ComboBox1, choix1, 0)) Then
Set d1 = CreateObject("Scripting.Dictionary")
tmp = UCase(Me.ComboBox1) & "*"
For Each c In choix1
If c Like tmp Then d1(c) = ""
Next c
Me.ComboBox1.List = d1.keys
Me.ComboBox1.DropDown
Else
p = Application.Match(Me.ComboBox1, choix1, 0)
Me.TextBox1 = Range("cp")(p)
End If
End Sub
Private Sub CommandButton1_Click()
ActiveCell = UCase(Me.ComboBox1)
ActiveCell.Offset(, 1) = Me.TextBox1
Unload Me
End Sub
Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Then CommandButton1_Click
End Sub |
Partager