coding a value to appear if it's before 2pm and one for if it's after

zilch4ry

Board Regular
Joined
Feb 27, 2011
Messages
76
hi everyone,

if there a way of coding a formula to say "if it is before 2pm show the text "Shift 1" and if it is after 2pm to show the text "shift 2"- it sounds simple but i can't see any possible way of doing this :eek:

If anybody could help in anyway possible, it will be much appreciated

cheers,



tom
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

zilch4ry

Board Regular
Joined
Feb 27, 2011
Messages
76
I managed to produce this code:

Code:
=IF(AND(J3-INT(J3)>="14:00:00"+0,J3-INT(J3)<="22:00:00"+0),"Staff Shift 2","Staff Shift 1")

Can anybody help me to write that if the times are between "22:00 and 06:00" then the text will read "closed"

Thank you ;)
 

repairman615

Well-known Member
Joined
Dec 21, 2009
Messages
1,885
Hello,

<TABLE style="WIDTH: 294pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=392><COLGROUP><COL style="WIDTH: 294pt; mso-width-source: userset; mso-width-alt: 6272" width=392><TBODY><TR style="HEIGHT: 15.75pt" height=21><TD style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BACKGROUND-COLOR: #eaf1dd; WIDTH: 294pt; HEIGHT: 15.75pt; BORDER-TOP: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid" class=xl65 height=21 width=392>=IF(RIGHT(NOW(),4)>=3333," Shift 2"," Shift 1")</TD></TR></TBODY></TABLE>
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
54,370
Office Version
  1. 365
Platform
  1. Windows
if there a way of coding a formula to say "if it is before 2pm show the text "Shift 1" and if it is after 2pm to show the text "shift 2
Try

=IF(MOD(J3,1)<14/24,"Shift 1","Shift2")
 

repairman615

Well-known Member
Joined
Dec 21, 2009
Messages
1,885

ADVERTISEMENT

Maybe this for all three conditions:

<TABLE style="WIDTH: 774pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=1032><COLGROUP><COL style="WIDTH: 774pt; mso-width-source: userset; mso-width-alt: 16512" width=1032><TBODY><TR style="HEIGHT: 15.75pt" height=21><TD style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BACKGROUND-COLOR: #eaf1dd; WIDTH: 774pt; HEIGHT: 15.75pt; BORDER-TOP: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid" id=td_post_2653266 class=xl65 height=21 width=1032>=IF(MID(A3,FIND(".",A3,1),4)+0>=0.25,IF(AND(MID(A3,FIND(".",A3,1),4)+0>=0.3333,MID(A3,FIND(".",A3,1),4)+0<0.9166)," Shift 2"," Closed")," Shift 1")</TD></TR></TBODY></TABLE>
 

repairman615

Well-known Member
Joined
Dec 21, 2009
Messages
1,885
<TABLE style="WIDTH: 851pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=1134><COLGROUP><COL style="WIDTH: 851pt; mso-width-source: userset; mso-width-alt: 18144" width=1134><TBODY><TR style="HEIGHT: 15.75pt" height=21><TD style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BACKGROUND-COLOR: #eaf1dd; WIDTH: 851pt; HEIGHT: 15.75pt; BORDER-TOP: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid" id=td_post_2653266 class=xl65 height=21 width=1134>=IF(MID(NOW(),FIND(".",NOW(),1),4)+0>=0.25,IF(AND(MID(NOW(),FIND(".",NOW(),1),4)+0>=0.3333,MID(NOW(),FIND(".",NOW(),1),4)+0<0.9166)," Shift 2"," Closed")," Shift 1")</TD></TR></TBODY></TABLE>
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,147
Messages
5,835,669
Members
430,373
Latest member
swartzfeger

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top