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
| Private Sub CommandButton3_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Tableau agent")
'Trouve la premiere ligne vide
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for a part number
If Trim(Me.TxtCtt.Value) = "" Then
Me.TxtCtt.SetFocus
MsgBox "Entrer un numéro de Matricule"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.TxtCtt.Value
ws.Cells(iRow, 2).Value = Me.TxtCiv.Value
ws.Cells(iRow, 3).Value = Me.TxtNom.Value
ws.Cells(iRow, 4).Value = Me.TxtPrn.Value
ws.Cells(iRow, 5).Value = Me.TxtPerio.Value
ws.Cells(iRow, 6).Value = Me.TxtPaie.Value
ws.Cells(iRow, 7).Value = Me.TxtRjt.Value
ws.Cells(iRow, 8).Value = Me.TxtImp.Value
ws.Cells(iRow, 9).Value = Me.TxtTel.Value
ws.Cells(iRow, 10).Value = Me.TxtPrt.Value
ws.Cells(iRow, 11).Value = Me.TxtcPdt.Value
ws.Cells(iRow, 12).Value = Me.TxtPdt.Value
'clear the data
Me.TxtCtt.Value = ""
Me.TxtCiv.Value = ""
Me.TxtNom.Value = ""
Me.TxtPrn.Value = ""
Me.TxtPerio.Value = ""
Me.TxtPaie.Value = ""
Me.TxtRjt.Value = ""
Me.TxtImp.Value = ""
Me.TxtTel.Value = ""
Me.TxtPrt.Value = ""
Me.TxtcPdt.Value = ""
Me.TxtPdt.Value = ""
End Sub |
Partager