I need a way to use the input on a userform to determine the date that will be displayed on the output. Here's my code:
If StatusBox.Value <= "23:59" And ShiftCode.Value = "AP" Then
Cells(emptyRow, 8).Value = ((Date - 1) + " " + StatusBox.Value + " " + "CEST")
Else
Cells(emptyRow, 8).Value = (Date + " " + StatusBox.Value + " " + "CEST")
End If
Basically I need the date to be displayed as Date - 1
when the input from StatusBox.Value is less than or equal to 11:59 PM or 23:59
the inputs on the StatusBox
field will always be in the 12-Hour format.
This solution assumes the following:
StatusBox.Value
is an Excel serial number formatted with a time format (no Date included) , as suchStatusBox.Value
is a decimal number with a value ranging from0
(zero) to0.99988426
, representing the times from0:00:00
(12:00:00 AM) to23:59:59
(11:59:59 P.M.). Therefore when this serial number reaches the 24 hours becomes1
(one).Based on the above replace this:
If StatusBox.Value <= "23:59"
...with this
If StatusBox.Value <= 1
...However if
StatusBox.Value
includes an[expected Date value]
then use this as replacement line:If StatusBox.Value <= [expected Date value]
...