I have the below table and in column labelled shift I want to be able to populate it with either "Day" or "Night" based on the column labelled Conducted on time only.
I still want to keep the date reference as this is used elsewhere.
For example If the time is between 6am and 6pm I want to label it as "Day". Between 6pm and 6am labelled as "Night".
I think I am down the right path with this if statement but it is not working for me.
Dim LastRow As Long
Dim i As Long
LastRow = Range("D" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Range("C" & i).Value < DateValue("DD/MM/YYYY 06:00:00") And Range("C" & i).Value > DateValue("DD/MM/YYYY 18:00:00") Then
Range("D" & i).Value = "EVENING"
End If
Next i
I still want to keep the date reference as this is used elsewhere.
For example If the time is between 6am and 6pm I want to label it as "Day". Between 6pm and 6am labelled as "Night".
I think I am down the right path with this if statement but it is not working for me.
Dim LastRow As Long
Dim i As Long
LastRow = Range("D" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Range("C" & i).Value < DateValue("DD/MM/YYYY 06:00:00") And Range("C" & i).Value > DateValue("DD/MM/YYYY 18:00:00") Then
Range("D" & i).Value = "EVENING"
End If
Next i
SHIFT ON: | Title Page_Conducted on | SHIFT | |
Shift B | 23/08/2023 11:58 | ||
Shift C | 22/08/2023 05:10 | ||
Shift C | 21/08/2023 05:18 | ||
Shift A | 19/08/2023 06:09 | ||
Shift B | 18/08/2023 18:49 | ||
Shift A | 18/08/2023 11:32 | ||
Shift C | 17/08/2023 17:09 | ||
17/08/2023 17:07 | |||
Shift D | 16/08/2023 05:07 | ||
Shift A | 15/08/2023 17:06 | ||
Shift B | 15/08/2023 05:33 | ||
Shift B | 14/08/2023 05:42 | ||
03/08/2023 11:05 | |||
Shift B | 27/07/2023 08:04 | ||
Shift D | 20/07/2023 05:05 | ||
Shift D | 19/07/2023 13:01 |