Im getting this error code on this part of the code without it everything works fine. """.Cells(1Row, 9).Value = Format(Now(), "dd/mm/yyyy hh:mm:ss")"""""
I just want to be able to add a timestamp.
Here is the full code:
Sub cmdSubmit_Click()
Dim ctl As Control
'Check User Input
If Me.txtApparatus.Value = "" Then
MsgBox "Please enter Apparatus.", vbExclamation, "Form Error"
Me.txtApparatus.SetFocus
Exit Sub
End If
If Me.txtReporter.Value = "" Then
MsgBox "Please enter your Name.", vbExclamation, "Form Error"
Me.txtReporter.SetFocus
Exit Sub
End If
'Write data to worksheet
'Copy input values to sheet.
Dim lRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Maintenance")
lRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws
.Cells(lRow, 1).Value = Me.txtApparatus.Value
.Cells(lRow, 2).Value = Me.txtAppearance.Value
.Cells(lRow, 3).Value = Me.cboPriority1.Value
.Cells(lRow, 4).Value = Me.txtMechanical.Value
.Cells(lRow, 5).Value = Me.cboPriority2.Value
.Cells(lRow, 6).Value = Me.txtElectrical.Value
.Cells(lRow, 7).Value = Me.cboPriority3.Value
.Cells(lRow, 8).Value = Me.txtReporter.Value
.Cells(1Row, 9).Value = Format(Now(), "dd/mm/yyyy hh:mm:ss")
End With
'Clear the form
For Each ctl In Me.Controls
If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then
ctl.Value = ""
Unload Me
End If
Next ctl
End Sub
Bookmarks