If Statement

vharp91

New Member
Joined
Jul 24, 2020
Messages
19
Office Version
  1. 2016
Platform
  1. Windows
Can someone help me with a formula that will have the value "Yes" in column T if the time in column I is between 7:00 & 19:00 (time is military). Thank you!

1722534874655.png
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Place this formula in cell T3 and copy down for all rows:
Excel Formula:
=IF(AND(MOD(I3,1)>=(7/24),MOD(I3,1)<=(19/24)),"Yes","")
 
Upvote 0
=IF( AND( I2-INT(I2) >= TIMEVALUE("07:00:00"), I2-INT(I2) <= TIMEVALUE("19:00:00")),"Yes","")

Book1
IJKLMNOPQRST
1
21/1/24 12:307:00 & 19:00 (time is military). Thank you!Yes
31/2/24 13:10Yes
41/3/24 13:50Yes
51/4/24 14:30Yes
61/5/24 15:10Yes
71/6/24 15:50Yes
81/7/24 16:30Yes
91/8/24 17:10Yes
101/9/24 17:50Yes
111/10/24 18:30Yes
121/11/24 19:10 
131/12/24 19:50 
141/13/24 20:30 
151/14/24 21:10 
161/15/24 21:50 
171/16/24 22:30 
181/17/24 23:10 
191/18/24 23:50 
201/20/24 0:30 
211/21/24 1:10 
221/22/24 1:50 
231/23/24 2:30 
241/24/24 3:10 
251/25/24 3:50 
261/26/24 4:30 
271/27/24 5:10 
281/28/24 5:50 
291/29/24 6:30 
301/30/24 7:10Yes
311/31/24 7:50Yes
322/1/24 8:30Yes
332/2/24 9:10Yes
342/3/24 9:50Yes
352/4/24 10:30Yes
36
Sheet1
Cell Formulas
RangeFormula
T2:T35T2=IF( AND( I2-INT(I2) >= TIMEVALUE("07:00:00"), I2-INT(I2) <= TIMEVALUE("19:00:00")),"Yes","")
 
Upvote 0
I realized this is not working for what I am intending and I believe it is because I worded the question incorrectly. I need the formula to pull in the value "Yes" in column U if the time in column I is between 7:00 PM & 7:00 AM? For Example, in the below data set, only I9 & I10 should pull in a "Yes" into U9 & U10.

1722536752208.png
 
Upvote 0
well you could do a NOT() on my formula so you get the opposite
=IF( NOT(AND( I2-INT(I2) >= TIMEVALUE("07:00:00"), I2-INT(I2) <= TIMEVALUE("19:00:00"))),"Yes","")
if you dont want the 7am and 19:00 - remove the =

or use an OR () , using Joe4 formula
=IF(OR(MOD(I3,1)<(7/24),MOD(I3,1)>(19/24)),"Yes","")

assumign you dont want a yes for 7pm or 7am
otherwise add the =

also you want in column U - i left in T - just change the formula so its in column U , NOT T
or is this an additional requirement for U and the OLD post for T

Book3
IJKLMNOPQRST
1
21/1/24 12:307:00 & 19:00 (time is military). Thank you! 
31/2/24 13:10 
41/3/24 13:50 
51/4/24 14:30 
61/5/24 15:10 
71/6/24 15:50 
81/7/24 16:30 
91/8/24 17:10 
101/9/24 17:50 
111/10/24 18:30 
121/11/24 19:10Yes
131/12/24 19:50Yes
141/13/24 20:30Yes
151/14/24 21:10Yes
161/15/24 21:50Yes
171/16/24 22:30Yes
181/17/24 23:10Yes
191/18/24 23:50Yes
201/20/24 0:30Yes
211/21/24 1:10Yes
221/22/24 1:50Yes
231/23/24 2:30Yes
241/24/24 3:10Yes
251/25/24 3:50Yes
261/26/24 4:30Yes
271/27/24 5:10Yes
281/28/24 5:50Yes
291/29/24 6:30Yes
301/30/24 7:10 
311/31/24 7:50 
322/1/24 8:30 
332/2/24 9:10 
342/3/24 9:50 
352/4/24 10:30 
Sheet1
Cell Formulas
RangeFormula
T2:T35T2=IF( NOT(AND( I2-INT(I2) >= TIMEVALUE("07:00:00"), I2-INT(I2) <= TIMEVALUE("19:00:00"))),"Yes","")
 
Upvote 0
You just need to change one word and flip the < and > signs in my formula, i.e.
Excel Formula:
=IF(OR(MOD(I3,1)<=(7/24),MOD(I3,1)>=(19/24)),"Yes","")
 
Upvote 0
well you could do a NOT() on my formula so you get the opposite
=IF( NOT(AND( I2-INT(I2) >= TIMEVALUE("07:00:00"), I2-INT(I2) <= TIMEVALUE("19:00:00"))),"Yes","")
Yep, NOT changes AND to OR, and changes >= to <= and changes <= to >=
 
Upvote 0
Solution
@vharp91 is this not the same question you asked in the thread below?

 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,173
Members
452,615
Latest member
bogeys2birdies

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
Back
Top