IF AND OR

kashifshahzad

New Member
Joined
May 17, 2014
Messages
17
I have Shift Start and Shift End columns in excel sheet. I calculated shift hours by formula. I want to modify this formula, based on the Status column.
if status = "P" or "P/2" or "HLF" calculate it's shift hours. otherwise, other than any mentioned status don't calculate hours and show it as blank. Moreover, if the worked hours is blank shift hours should also be blank regardless of any status.

Shift Test.xlsx
AMNOP
1DateWorked HoursO.T HoursStatusshift hours
219-08-202310:48P11:00
320-08-202310:50P11:00
421-08-202310:50P11:00
522-08-202310:52P11:00
623-08-202310:51P11:00
724-08-202310:45P11:00
819-08-2023LEV11:00
920-08-2023LEV11:00
1021-08-2023LEV11:00
1122-08-202309:00P/211:00
1223-08-202310:36P11:00
1324-08-202310:32P11:00
1419-08-202310:56P11:00
1520-08-202310:41P11:00
1621-08-202311:1000:10P11:00
1722-08-202311:0400:04P11:00
1823-08-202311:00P11:00
1924-08-202310:59P11:00
2019-08-202310:57P11:00
2120-08-202311:1100:11P11:00
2221-08-202311:1200:12P11:00
2322-08-202311:1500:15HLF11:00
2423-08-202311:0400:04P11:00
2524-08-202311:0600:06P11:00
2619-08-202308:49P9:00
2720-08-202309:0200:02P9:00
2821-08-202308:54P9:00
2922-08-202308:59P9:00
3023-08-202308:56P9:00
3124-08-202309:0200:02P9:00
3219-08-202311:1800:18P11:00
3320-08-202311:2000:20P11:00
3421-08-202311:1600:16P11:00
3522-08-202311:1900:19P11:00
3623-08-202311:2100:21P11:00
3724-08-202311:0800:08P11:00
3819-08-202308:27P9:00
3920-08-202308:33P9:00
4021-08-202308:43P9:00
4122-08-202308:31P9:00
4223-08-202308:21P9:00
4324-08-2023A9:00
4419-08-202308:47P9:00
4520-08-202308:50P9:00
4621-08-202308:47P9:00
4722-08-202308:47P9:00
4823-08-202308:54P9:00
4924-08-202308:46P9:00
5019-08-202310:59P11:00
5120-08-202311:0200:02P11:00
5221-08-202311:0300:03P11:00
5322-08-202311:00P11:00
5423-08-202311:0200:02P11:00
5524-08-202311:0600:06P11:00
5619-08-202308:14P8:30
5720-08-202308:24P8:30
5821-08-202308:24P8:30
5922-08-202308:30P8:30
6023-08-202308:26P8:30
6124-08-202308:19P8:30
6219-08-202308:4900:49P8:00
6320-08-202309:0201:02P8:00
6421-08-202308:5400:54P8:00
6522-08-202308:5900:59P8:00
6623-08-202308:5600:56P8:00
6724-08-202308:5600:56P8:00
6819-08-202310:56P11:00
6920-08-202310:41P11:00
7021-08-202307:06P11:00
7122-08-2023LEV11:00
7223-08-2023LEV11:00
7324-08-2023LEV11:00
7419-08-202309:2000:20P9:00
7520-08-202309:1400:14P9:00
Sheet1
Cell Formulas
RangeFormula
P2:P75P2=IF(([@[Shift End]]-[@[Shift start]])<0,1-([@[Shift start]]-[@[Shift End]]),([@[Shift End]]-[@[Shift start]]))
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Shift Test.xlsx
AGHMOP
1DateShift startShift EndWorked HoursStatusshift hours
219-08-20235:0016:0010:48P11:00
320-08-20235:0016:0010:50P11:00
421-08-20235:0016:0010:50P11:00
522-08-20235:0016:0010:52P11:00
623-08-20235:0016:0010:51P11:00
724-08-20235:0016:0010:45P11:00
819-08-20235:0016:00LEV11:00
920-08-20235:0016:00LEV11:00
1021-08-20235:0016:00LEV11:00
1122-08-20235:0016:0009:00P/211:00
1223-08-20235:0016:0010:36P11:00
1324-08-20235:0016:0010:32P11:00
1419-08-20235:0016:0010:56P11:00
1520-08-20235:0016:0010:41P11:00
1621-08-20235:0016:0011:10P11:00
1722-08-20235:0016:0011:04P11:00
1823-08-20235:0016:0011:00P11:00
1924-08-20235:0016:0010:59P11:00
2019-08-20235:0016:0010:57P11:00
2120-08-20235:0016:0011:11P11:00
2221-08-20235:0016:0011:12P11:00
2322-08-20235:0016:0011:15HLF11:00
2423-08-20235:0016:0011:04P11:00
2524-08-20235:0016:0011:06P11:00
2619-08-20237:0016:0008:49P9:00
2720-08-20237:0016:0009:02P9:00
2821-08-20237:0016:0008:54P9:00
2922-08-20237:0016:0008:59P9:00
3023-08-20237:0016:0008:56P9:00
3124-08-20237:0016:0009:02P9:00
3219-08-20235:0016:0011:18P11:00
3320-08-20235:0016:0011:20P11:00
3421-08-20235:0016:0011:16P11:00
3522-08-20235:0016:0011:19P11:00
3623-08-20235:0016:0011:21P11:00
Sheet1
Cell Formulas
RangeFormula
P2:P36P2=IF(([@[Shift End]]-[@[Shift start]])<0,1-([@[Shift start]]-[@[Shift End]]),([@[Shift End]]-[@[Shift start]]))
 
Upvote 0

Forum statistics

Threads
1,215,757
Messages
6,126,695
Members
449,331
Latest member
smckenzie2016

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