Compare times using the timeserial in VBA in Excel. Sort timestamps into shifts by using the timeserial in VBA. Set a range of times for each shift.
Sub shifts()
Dim i As Integer
i = 2
Do While Cells(i, 1)(not equal symbol) “”
Worksheets(“sheet1”).Select
If Cells(i, 1).Value (greater than) TimeSerial(7, 0, 0) And Cells(i, 1).Value (less than ) TimeSerial(16, 0, 0) Then
Cells(i, 2) = “day”
Else
If Cells(i, 1).Value (greater than) TimeSerial(16, 0, 0) And Cells(i, 1).Value (less than) TimeSerial(24, 0, 0) Then
Cells(i, 2) = “Aft”
Else
Cells(i, 2) = “night”
End If
End If
i = i + 1
Loop
End Sub
For more help visit my website
I am able to provide online help on your computer for a reasonable rate.
MY videos are all created on Camtasia.
Follow me on Facebook
Watch more new videos about Excel Office | Synthesized by Mindovermetal English
This is a great video thanks, Is it possible to take it a step further and name the shift that was on a specific date if you have 4 shifts A to D that work a routine pattern
I can't imagine you have just only 5 likes on this video, thank you for solving this