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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| Private Sub UserForm_Initialize()
Dim Madate As Date
'Incrémentation de la date
CbBox_Date.Value = Madate
'Zone de liste vierge
CbBox_Area.Value = ""
CbBox_Type.Value = ""
End Sub
Private Sub CdB_Ok1_Click()
Dim cbbox As Variant
Dim auditor1 As String, auditor2 As String, auditor3 As String, auditor4 As String, auditor5 As String
Application.ScreenUpdating = False
'Activation de la feuille de recueil
With Worksheets("Audit Database")
.activate
'Copier la dernière ligne pour formater le remplissage
Rows("2:2").Select
Selection.Copy
Rows("2:2").Select
Selection.Insert Shift:=xlDown
Range("A2").Select
Application.CutCopyMode = False
Selection.ClearContents
'Remplir les cellules avec les valeurs des ComboBox et TextBox
Cells(2, 1) = CDate(Format(CStr(CbBox_Date.Value), "mm/dd/yyyy"))
Cells(2, 2) = CbBox_Area.Value
auditor1 = CbBox_auditor1.Value
auditor2 = CbBox_auditor2.Value
auditor3 = CbBox_auditor3.Value
auditor4 = CbBox_auditor4.Value
auditor5 = CbBox_auditor5.Value
Cells(2, 3) = auditor1 & ", " & auditor2 & ", " & auditor3 & ", " & auditor4 & ", " & auditor5
Cells(2, 4) = CbBox_Type.Value
End With
With Worksheets("Audit Form")
.activate
Cells(1, 43) = CDate(Format(CStr(CbBox_Date.Value), "mm/dd/yyyy"))
Cells(1, 23) = auditor1 & ", " & auditor2 & ", " & auditor3 & ", " & auditor4 & ", " & auditor5
Cells(3, 4) = CbBox_Area.Value
Cells(3, 44) = CbBox_Type.Value
'Open the next questionnaire
Q1_Safety.Show
' 'Cancel useform
' Unload Me
End With
End Sub
Function Madate(Tmp As String) As Date
Select Case Application.International(xlDateOrder)
'0 = month-day-year
'1 = day-month-year
'2 = year-month-day
Case 0
Me.Madate = CDate(Format(Tmp, "mm/dd/yyyy"))
Case 1
Me.Madate = CDate(Format(Tmp, "dd/mm/yyyy"))
Case 2
Me.Madate = CDate(Format(Tmp, "yyyy/mm/dd"))
End Select
End Function |
Partager