Dim Peut As Boolean 'pour éviter des appels de macro intempestifs (laisser ici)
'Quitter
Private Sub BtnQuitter_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim aa As Variant
aa = Feuil1.Range("A9:M" & Feuil1.Range("A65536").End(xlUp).Row)
ListBox1.List = aa
Dim n As Byte
For n = 65 To 90
ComboBox1.AddItem Chr(n) 'caractère dont le code ASCII est une lettre majuscule
Next
Peut = True 'libère le changement
ComboBox1.SetFocus
End Sub
Private Sub Combobox1_Change()
If Peut = False Then Exit Sub
Peut = False 'empêche le changement
ListBox1.Clear
For Each cel In Sheets("Récap").Range("W:W").SpecialCells(xlCellTypeConstants)
If UCase(Left(cel.Value, 1)) = ComboBox1 Then
ListBox1.AddItem (cel.Value)
For C = 0 To 10
ListBox1.List(ListBox1.ListCount - 1, C) = Sheets("Récap").Cells(cel.Row, C + 1)
Next
End If
Next
If ListBox1.ListCount = 0 Then MsgBox "Aucun élément trouvé sur la feuille", vbInformation, "Attention,"
ComboBox1 = ""
Peut = True 'libère le changement
End Sub
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim ListIndex As Integer
For ListIndex = 0 To (ListBox1.ListCount - 1)
If ListBox1.Selected(ListIndex) = True Then
Me.TextBox1 = Me.ListBox1.List(ListIndex, 0) ' N° Cde
Me.TextBox4 = Me.ListBox1.List(ListIndex, 1) ' Nom
Me.TextBox2 = Me.ListBox1.List(ListIndex, 3) ' Date
Me.TextBox7 = Me.ListBox1.List(ListIndex, 2) ' Prénom
Me.TextBox3 = Me.ListBox1.List(ListIndex, 4) ' Adresse
Me.TextBox5 = Format(Me.ListBox1.List(ListIndex, 5), "00000") ' CP
Me.TextBox8 = Me.ListBox1.List(ListIndex, 6) ' Ville
Me.TextBox6 = Me.ListBox1.List(ListIndex, 7) ' Tél
Me.TextBox10 = Format(Me.ListBox1.List(ListIndex, 8), "#, ##0.00€") 'Montant
' Me.TextBox9 = Me.ListBox1.List(ListIndex, 15) 'Date de Réglement
Exit Sub
End If
'MsgBox ListBox1.ListIndex + 9
End Sub