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
| Set Wb1 = Workbooks("Book1.xlsb")
Set Ws1 = Wb1.Worksheets("Sheet 1")
Set Ws2 = Wb1.Worksheets("Sheet 2")
Set Ws3 = Wb1.Worksheets("Sheet 3")
If Me.Controls("TxtBox1").Value = "" Then
MsgBox "Veuillez la première case", vbExclamation + vbOKOnly
Exit Sub
End If
'------------------------------------------------------------------------
'Loop on each textbox written
'------------------------------------------------------------------------
For j = 1 To 10
If Me.Controls("TxtBox1" & j).Value <> "" And Me.Controls("TxtBox3" & j).Value = "" Or Me.Controls("TxtBox4" & j).Value = "" Then
MsgBox "Veuillez renseigner les textbox " & j & "", vbExclamation + vbOKOnly
Exit Sub
Else
'Write the values into the cells
If Me.Controls("TxtBox_Action" & j).Value <> "" And Me.Controls("TxtBox_Pilote" & j).Value <> "" And Me.Controls("TxtBox_Deadline" & j).Value <> "" Then
Ws2.Cells(j + 1, 1) = Label_1.Caption
Ws2.Cells(j + 1, 2) = CDate(Format(CStr(Date), "dd/mm/yyyy"))
Ws2.Cells(j + 1, 3) = WsHAP.Cells(1, 1)
Ws2.Cells(j + 1, 4) = Me.Controls("Label_2" & j).Caption
Ws2.Cells(j + 1, 5) = Label_3.Caption
Ws2.Cells(j + 1, 6) = Label_4.Caption
Ws2.Cells(j + 1, 7) = Me.Controls("TxtBox1" & j).Value
Ws2.Cells(j + 1, 8) = Me.Controls("TxtBox2" & j).Value
Ws2.Cells(j + 1, 9) = Me.Controls("TxtBox3" & j).Value
Ws2.Cells(j + 1, 10) = CDate(Format(CStr(Me.Controls("TxtBox4" & j).Value), "dd/mm/yyyy"))
'Write the values of closed action
If Ws3.Cells(j, 3) <> "" Then
Ws2.Cells(j + 1, 13) = CDate(Format(CStr(Date), "dd/mm/yyyy"))
Ws2.Cells(j + 1, 14) = Ws3.Cells(1, 1)
Ws2.Cells(j + 1, 15) = Ws3.Cells(j, 3)
End If
' End If
End If
Next j |
Partager