# Formula counting staff hours

#### Drexl88

##### Board Regular
Hi,

I have the below formula that counts columns D - Q working out the hours an employee works based on the type of shift indicated by using "D", "N","DC", "B/D" "TWL". If an employee covers part shifts it is indicated as time (example 13:00 - 17:00). I've encountered a problem with the last part of the formula that counts the hours between time on a part shift (example, 13:00 -17:00 = 4hrs). If the employee starts the part shift one day and works past midnight (example, 20:00 - 02:00 it returns minus hours worked and reduces the overall hours.

Any help would be greatly appreciated.

=SUM(COUNTIF(D17:Q17, {"D","N","DC","B/D"}))*11.75+COUNTIF(D17:Q17,"TWL")*11.5+SUMPRODUCT(--IFERROR(RIGHT(D17:Q17,5)-LEFT(D17:Q17,5),0))*24

### Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Replies
3
Views
159
Replies
11
Views
161
Replies
0
Views
64
Replies
8
Views
117
Replies
6
Views
455

1,130,029
Messages
5,639,623
Members
417,101
Latest member
amoverton2

### 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.

### Which adblocker are you using?

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

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