Hello SamT,
i got another error check attchment please
Capture2.jpg
Private Sub CommandButton1_Click()
Dim sh As Worksheet, StartTime As Date, EndTime As Date, NextRow As Long, last_Row As Long
Set sh = ThisWorkbook.Sheets("outputs")
last_Row = Application.WorksheetFunction.CountA(sh.Range("A:A"))
NextRow = last_Row + 1
If Len(TextBox4) * Len(ComboBox4) = 0 Then 'Either start Date or start Time is empty
MsgBox "Gotta have a Start Time"
Exit Sub
End If
StartTime = CDate(TextBox4 & " " & ComboBox4)
sh.Rows(NextRow).Cells("G") = Format(StartTime, "mm/dd/yyyy hh:mm")
If Len(TextBox5) + Len(ComboBox5) > 0 And Len(TextBox5) * Len(ComboBox5) = 0 Then 'only one is empty
MsgBox "Gotta fill in neither or both endtime boxes."
Exit Sub
End If
If Len(TextBox5) + Len(ComboBox5) = 0 Then Exit Sub 'No end Time, all done
EndTime = CDate(TextBox5 & " " & ComboBox5)
If EndTime <= Startime Then
MsgBox "end time gotta be after start time"
Exit Sub
End If
With sh.Rows(NextRow)
.Cells("H") = Format(EndTime, "mm/dd/yyyy hh:mm")
.Cells("I") = Format(EndTime - StartTime, "0m Months, dd Days, and 0h Hours, 0m Minutes")
'That simple line won't work for the remaining Time. You will need to check the number of months,
'and days remaining, then decide what you want displayed.
'Use a separate Function.
'.Cells("I") = Customformattingfunction(StartTime, EndTime)
End With
Call Refresh_Data
TextBox1.Value = Sheet18.Range("A1").CurrentRegion.Rows.Count
End Sub