Excel Function Friday: Track Driver Hours
Thanks for your formula suggestions on Wednesday’s blog post about promotional pricing. Here’s another formula example, and I’m sure you’ll have alternate methods for this problem too.
In some countries, there are limits to the hours that truck drivers can work in a string of consecutive days. In this example, the limit is 60 hours, in any period of 7 consecutive days.
The maximum hours is entered in cell C1, and the number of consecutive days is entered in cell F1. If the regulations change, it will be easy to change those settings.
Calculate the Remaining Hours
To help prevent drivers from going over their limits, we’ll set up a table where the daily hours are entered.
The date and driver name are entered in each row. In column D, a SUMPRODUCT formula calculates how many hours the driver has remaining, in the current 7 day period.
The SUMPRODUCT formula checks all the rows above, where the date within the 7 day range, and the driver name matches the current row.
That amount is subtracted from the maximum hours allowed.
Calculate the Consecutive Hours
The current hours are typed in column E, and a simple formula in column F calculates the total for a consecutive 7 day period.
Highlight the Violations
With Conditional Formatting, you can highlight any cells where the total consecutive hours exceeds the maximum allowed.
- On the Ribbon’s Home tab, click Conditional Formatting
- Click Highlight Cells Rules, and then click Greater Than
- In the Greater Than dialog box, select cell C1 as the limit in the text box.
- Select one of the preset format, or create a custom format to highlight the cells.
View the Results
With the conditional formatting applied, it’s easy to see where the trouble is. In this example, Lou has gone over his limit on April 10th.
Download the Driver Limit Sample File
To see the data and the formulas, you can download the Driver Hours Limit sample file. The file is zipped, and is in Excel 2003 format. There is also a pivot table that totals the drivers’ hours per calendar week.