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 44 45 46
| Dim MàJListe As Boolean
Private Sub Userform_Initialize()
ListBox1.RowSource = "Tableau1"
ListBox1.ColumnCount = 5
ListBox1.ColumnHeads = True
ListBox1.ListIndex = 0
MàJListe = True
End Sub
Private Sub ListBox1_Change()
If ListBox1.ListIndex = -1 Then
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
Else
MàJListe = False
TextBox1.Text = ListBox1.List(ListBox1.ListIndex, 0)
TextBox2.Text = ListBox1.List(ListBox1.ListIndex, 1)
TextBox3.Text = ListBox1.List(ListBox1.ListIndex, 2)
TextBox4.Text = ListBox1.List(ListBox1.ListIndex, 3)
TextBox5.Text = ListBox1.List(ListBox1.ListIndex, 4)
MàJListe = True
End If
End Sub
Private Sub TextBox1_Change()
If MàJListe = True Then Range("Tableau1").Cells(ListBox1.ListIndex + 1, 1) = TextBox1.Text
End Sub
Private Sub TextBox2_Change()
If MàJListe = True Then Range("Tableau1").Cells(ListBox1.ListIndex + 1, 2) = TextBox2.Text
End Sub
Private Sub TextBox3_Change()
If MàJListe = True Then Range("Tableau1").Cells(ListBox1.ListIndex + 1, 3) = TextBox3.Text
End Sub
Private Sub TextBox4_Change()
If MàJListe = True Then Range("Tableau1").Cells(ListBox1.ListIndex + 1, 4) = TextBox4.Text
End Sub
Private Sub TextBox5_Change()
If MàJListe = True Then Range("Tableau1").Cells(ListBox1.ListIndex + 1, 5) = TextBox5.Text
End Sub |
Partager