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
| Private Sub CommandButton3_Click()
If ComboBox1.Text = "" Then
MsgBox "il faut choisir un nom"
Exit Sub
End If
For i = 3 To Range("B" & Rows.Count).End(xlUp).Row
If ComboBox1.Text = Cells(i, 2).Value Then
Cells(i, 5).Value = textbox3.Text
Cells(i, 6).Value = textbox4.Text
Cells(i, 7).Value = textbox5.Text
Cells(i, 8).Value = textbox6.Text
Cells(i, 9).Value = textbox7.Text
Exit For
End If
Next
End Sub
Private Sub CommandButton4_Click()
'pour bouton next
For i = 3 To Range("B" & Rows.Count).End(xlUp).Row
If Cells(i, 5).Value = "" Or Cells(i, 6).Value = "" Or Cells(i, 7).Value = "" Or _
Cells(i, 8).Value = "" Or Cells(i, 9).Value = "" Then
'si il manque une donnée on récupère les autres
ComboBox1.Text = Cells(i, 2).Value
textbox3.Text = Cells(i, 5).Value
textbox4.Text = Cells(i, 6).Value
textbox5.Text = Cells(i, 7).Value
textbox6.Text = Cells(i, 8).Value
textbox7.Text = Cells(i, 9).Value
Exit For
End If
msgbox "les champs ont été tous remplis"
Next
End Sub |
Partager