Option Explicit
Private Sub AjouterClient_Click()
Dim i As Integer
Dim k As Long
With UsfNew
If Len(.txtNom) = 0 Then
.txtNom.SetFocus
MsgBox "Nom Prénom vide", vbOKOnly + vbInformation, "Saisie"
Exit Sub
End If
If Len(.txtCompagnie) = 0 Then
.txtCompagnie.SetFocus
MsgBox "Compagnie vide", vbOKOnly + vbInformation, "Saisie"
Exit Sub
End If
' ...... etc
End With
For i = 0 To UsfNew.ListBoxNum.ListCount - 1
If UsfNew.ListBoxNum.Selected(i) Then
k = UsfNew.ListBoxNum.List(i)
With ShListe
.Cells(k + 2, 3) = UsfNew.txtNom
.Cells(k + 2, 4) = UsfNew.txtCompagnie
' ..... etc
End With
End If
Next i
MajListBoxNum
End Sub
Private Sub MajListBoxNum()
Dim i As Long
Dim LastRow As Long
With ShListe
With UsfNew
.ListBoxNum.Visible = False
.ListBoxNum.Clear
End With
LastRow = .Range("A" & Rows.Count).End(xlUp).Row
For i = 3 To LastRow
If .Cells(i, 2) <> "a" Then
UsfNew.ListBoxNum.AddItem .Cells(i, 1)
End If
Next i
UsfNew.ListBoxNum.Visible = True
End With
End Sub
Private Sub UserForm_Initialize()
Dim i As Integer
Dim LastRow As Long
With ShListe
LastRow = .Range("A" & Rows.Count).End(xlUp).Row
For i = 3 To LastRow
If .Cells(i, 2) <> "a" Then
UsfNew.ListBoxNum.AddItem .Cells(i, 1)
End If
Next i
End With
End Sub