IF Statement with TRUE / FALSE Condition

gregory77

New Member
Joined
Jul 28, 2017
Messages
3
Given the table, I have the following criteria (times in 24 hour):

IF 6:00 to 10:00 AND weekday = Y THEN Category = 1
IF 10:01 to 16:00 AND weekday = Y THEN Category = 2
IF 16:01 to 20:00 AND weekday = Y THEN Category = 3

IF 06:00 to 20:00 AND weekday = N THEN Category = 4

There are no times before 06:00 or after 20:00. I am trying to contrive the formula for use in F2.

My efforts have been met with disastrous results. Any assistance you could provide would be fantastic and greatly appreciated! Thank you so much!

-G

Table:

D E F
1 Time Weekday? Category

2 06:00 Y

3 06:15 N

4 11:30 Y

5 15:45 Y

6 16:30 Y

7 19:00 N

8 07:15 N

9 17:30 N

10 09:30 Y

11 18:30 N
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Try
Code:
=IF(AND(E2>=TIMEVALUE("6:00 am"),E2<=TIMEVALUE("10:00 am"),F2="y"),1,IF(AND(E2>=TIMEVALUE("10:01 am"),E2<=TIMEVALUE("4:00 pm"),F2="y"),2,IF(AND(E2>=TIMEVALUE("4:01 pm"),E2<=TIMEVALUE("8:00 pm"),F2="y"),3,IF(F2="n",4))))
 
Upvote 0
Scott T....thank you for the quick reply! Ok, looks like everything is working. However, when Time = 20:00 and Weekday = Y, it evaluates to FALSE. I tried tweaking to no avail. Any suggestions? Again, much appreciated!!!!
 
Upvote 0
It works for me

[TABLE="class: grid, width: 192"]
<tbody>[TR]
[TD="width: 64, bgcolor: transparent, align: right"][/TD]
[TD="width: 64, bgcolor: transparent, align: right"]D
[/TD]
[TD="width: 64, bgcolor: transparent"]E
[/TD]
[TD="width: 64, bgcolor: transparent, align: right"]F
[/TD]
[/TR]
[TR]
[TD="width: 64, bgcolor: transparent, align: right"]2
[/TD]
[TD="width: 64, bgcolor: transparent, align: right"]20:00
[/TD]
[TD="width: 64, bgcolor: transparent"]y
[/TD]
[TD="width: 64, bgcolor: transparent, align: right"]3
[/TD]
[/TR]
</tbody>[/TABLE]

If you change the format of the cell with 20:00 to General do you get 0.833333?
Check that the y does not have any spaces around. The only thing in the cells should be y.
 
Upvote 0
Strange....If I retype Column D (Time), it works. Column D was originally a calculated field. All the other times work. Weird but probably formatting since I retrieved this from a database. I appreciate it Scott T. Many thanks.

G
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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