Bonjour,
Faire les modifications suivantes dans VBA:
dans Module1, ajouter ce code:
Sub Init_ListeNoms()
Sheets("Tableau").Select
derligne = range("A" & Rows.Count).End(xlUp).Row
range("A10:A" & derligne).Name = "N_P"
End Sub
dans le formulaire gestion (bouton supprimer)
Private Sub CommandButton3_Click()
'supprimer
If MsgBox("Voulez-vous supprimer cet enregistrement: " & Me.ListBox1 & "?", vbCritical + vbYesNo + _
vbDefaultButton2, "Suppression") <> vbYes Then Exit Sub
WsS.Rows(Me.ListBox1.ListIndex + 10).Delete
InitListBox
Init_ListeNoms
End Sub
et bouton ajouter
Private Sub CommandButton1_Click()
'Ajouter
Dim ligne As Long
Dim col As Integer
If Trim(Me.TextBox1) = "" Then
MsgBox "Le nom est obligatoire!"
Exit Sub
End If
With WsS
ligne = .range("A" & Rows.Count).End(xlUp).Row + 1
.Cells(ligne, 1) = UCase(Me.TextBox1)
.Cells(ligne, 2) = Application.Proper(Me.TextBox2)
For col = 3 To WsS.Cells(7, Cells.Columns.Count).End(xlToLeft).Column Step 3
If Me.ComboBox1.Value = .Cells(7, col) Then
.Cells(ligne, col) = Format(Me.ComboBox2, Text)
.Cells(ligne, col + 1) = Format(Me.TextBox4, Text)
.Cells(ligne, col + 2) = Me.TextBox5
End If
Next col
End With
InitListBox
Init_ListeNoms
End Sub
La liste des Noms et Prénoms (N_P) est mise à jour à chaque ajout ou suppression.
Cdt
Henri