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 32 33 34 35 36 37 38 39 40 41 42 43
| Private Sub ComboBox_ID_Change()
With Me
' gestion des identifiants inexistants
If .ComboBox_ID.ListIndex = -1 Then
.ComboBox_ID.Value = ""
.TextBox_NOM.Value = ""
.TextBox_PRENOM.Value = ""
Exit Sub
End If
' récupération du nom et du prénom lié à l'identifiant choisi dans le menu déroulant
.TextBox_NOM.Value = Worksheets("Synthèse").ListObjects(1).Range(.ComboBox_ID.ListIndex + 2, 3)
.TextBox_PRENOM.Value = Worksheets("Synthèse").ListObjects(1).Range(.ComboBox_ID.ListIndex + 2, 4)
End With
End Sub
Private Sub CommandButton_MODIFIER_Click()
With Me
' gestion du clic sur le bouton alors qu'on a rien choisi
If .ComboBox_ID.Value = "" Then
MsgBox "Veuillez choisir un identifiant et effectuer les modifications souhaitées"
Exit Sub
Else
' modification des nom/prénoms dans les 13 tableaux
For i = 1 To 13
Worksheets(i).ListObjects(1).Range(.ComboBox_ID.ListIndex + 2, 3).Value = .TextBox_NOM.Value
Worksheets(i).ListObjects(1).Range(.ComboBox_ID.ListIndex + 2, 4).Value = .TextBox_PRENOM.Value
Next i
End If
End With
End Sub
Private Sub UserForm_Initialize()
' chargement de la liste des identifiants du tableau de synthèse
Dim Tablo
Tablo = Worksheets("Synthèse").ListObjects(1).ListColumns(1).DataBodyRange
Me.ComboBox_ID.List = Tablo
Application.ScreenUpdating = True
End Sub |
Partager