Time vs. shift

scolodny

New Member
Joined
Jan 29, 2004
Messages
4
I am pulling in data to my spreadsheet from an external source. I have used NOW() and defined its format as military time. I am wanting to determine, based on that time, what shift I am currently in. Shifts are 7 - 2, 2 - 11, and 11 to 7. I have been playing this for awhile with no luck. Can anyone provide a resolution?
 

PawPawGary

Board Regular
Joined
Dec 29, 2007
Messages
61
Here's one way to accomplish what you want:
Change the cell where you have NOW() formatted as military time to =TIME(HOUR(NOW()),MINUTE(NOW()),0) and define this cell as TEST.
Create four defined Names as follows:
ATIME defined as =TIME(19,0,0)
BTIME defined as =TIME(2,0,0)
CTIME defined as =TIME(11,0,0)

In the cell where you want the shift to be displayed enter this formula:
=IF(OR(test>atime,test<=btime),"Shift A",IF(AND(test>btime,test<=ctime),"Shift B","Shift C"))

This assumes that the shift begins after 7:00 and ends on or before 2:00 (14:00).

Hope this helps,
Gary
 

Forum statistics

Threads
1,081,691
Messages
5,360,631
Members
400,592
Latest member
badgergurl

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top