# 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

Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Replies
2
Views
43
Replies
11
Views
156
Replies
0
Views
9
Replies
6
Views
415
Replies
2
Views
179

1,128,107
Messages
5,628,731
Members
416,333
Latest member
Time2Learn

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