IF statement with time format

kelvin_9

Active Member
Joined
Mar 6, 2015
Messages
460
Office Version
  1. 2019
greeting to all

wondering how can i return A if start time and end time is 8:45-18:15 or B if start time and end time is 9:15-18:45
ps: the report genereated with time format: [$-en-US,1]h:mm
thank you very much for your guidence

Copy of HKDL Schedule List_Marty_Jul 28 - Aug 10.xls
IJK
98:4518:15A
108:4518:15A
118:4518:15A
128:4518:15A
138:4518:15A
148:4518:15A
158:4518:15A
168:4518:15A
178:4518:15A
189:1518:45B
199:1518:45B
209:1518:45B
219:1518:45B
229:1518:45B
239:1518:45B
Sheet1
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
try

Excel Formula:
=IF(AND(TEXT(A1,"HH:MM")=TEXT("08:45","HH:MM"),TEXT(B1,"HH:MM")=TEXT("18:15","HH:MM")),"A",IF(AND(TEXT(A1,"HH:MM")=TEXT("09:15","HH:MM"),TEXT(B1,"HH:MM")=TEXT("18:45","HH:MM")),"B",""))
 
Upvote 0
thank you for your reply, SunnyAlv

amazing and i tried 2 more criteria, it works too

thank you very much

Copy of HKDL Schedule List_Marty_Jul 28 - Aug 10.xls
JKL
118:4518:15A
128:4518:15A
138:4518:15A
148:4518:15A
158:4518:15A
168:4518:15A
178:4518:15A
188:4518:15A
198:4518:15A
209:1518:45B
219:1518:45B
229:1518:45B
239:1518:45B
249:1518:45B
259:1518:45B
2610:1517:45C
2712:0021:30D
2812:0021:30D
2912:0021:30D
3012:0021:30D
3112:0021:00undefined
Sheet1
Cell Formulas
RangeFormula
L11:L31L11=IF(AND(TEXT(J11,"HH:MM")=TEXT("08:45","HH:MM"),TEXT(K11,"HH:MM")=TEXT("18:15","HH:MM")),"A",IF(AND(TEXT(J11,"HH:MM")=TEXT("09:15","HH:MM"),TEXT(K11,"HH:MM")=TEXT("18:45","HH:MM")),"B",IF(AND(TEXT(J11,"HH:MM")=TEXT("10:15","HH:MM"),TEXT(K11,"HH:MM")=TEXT("17:45","HH:MM")),"C",IF(AND(TEXT(J11,"HH:MM")=TEXT("12:00","HH:MM"),TEXT(K11,"HH:MM")=TEXT("21:30","HH:MM")),"D","undefined"))))
 
Upvote 0
When in the first column you have 8:45, the second columna always has 18:15? And for the case that in the first column is 9:15, the second is always 18:45? Or could there be any combination of time values in both columns?
 
Upvote 0
Another option:

Book1
ABC
18:4518:15A
28:4518:15A
38:4518:15A
48:4518:15A
58:4518:15A
68:4518:15A
78:4518:15A
88:4518:15A
98:4518:15A
109:1518:45B
119:1518:45B
129:1518:45B
139:1518:45B
149:1518:45B
159:1518:45B
1610:1517:45C
1712:0021:30D
1812:0021:30D
1912:0021:30D
2012:0021:30D
2112:0021:00not defined
Sheet1
Cell Formulas
RangeFormula
C1:C21C1=IFERROR(INDEX({"A";"B";"C";"D"}, MATCH(TEXT(A1, "h:mm")&"-"&TEXT(B1, "h:mm"),{"8:45-18:15";"9:15-18:45";"10:15-17:45";"12:00-21:30"},0)), "not defined")
 
Upvote 0
If you won't have more than 26 possibilities, this should work too:

=IFERROR(CHAR(64+MATCH(TEXT(A1,"h:mm")&"-"&TEXT(B1,"h:mm"),{"8:45-18:15";"9:15-18:45";"10:15-17:45";"12:00-21:30"},0)),"not defined")

Book3
ABC
18:4518:15A
28:4518:15A
38:4518:15A
48:4518:15A
58:4518:15A
68:4518:15A
78:4518:15A
88:4518:15A
98:4518:15A
109:1518:45B
119:1518:45B
129:1518:45B
139:1518:45B
149:1518:45B
159:1518:45B
1610:1517:45C
1712:0021:30D
1812:0021:30D
1912:0021:30D
2012:0021:30D
2112:0021:00not defined
Sheet1
Cell Formulas
RangeFormula
C1:C21C1=IFERROR(CHAR(64+MATCH(TEXT(A1,"h:mm")&"-"&TEXT(B1,"h:mm"),{"8:45-18:15";"9:15-18:45";"10:15-17:45";"12:00-21:30"},0)),"not defined")
 
Upvote 0

Forum statistics

Threads
1,221,469
Messages
6,160,028
Members
451,611
Latest member
PattiButche

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