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.
Driver Limits
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.
Worksheet Entry Cells
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 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 columns B and C.
In column D, the following SUMPRODUCT formula calculates how many hours the driver has remaining, in the current 7 day period.
=$C$1-(SUMPRODUCT(--($B$4:$B4>=$B4-F$1-1), --($C$4:$C4=$C4), --($E$4:$E4))-E4)
The SUMPRODUCT formula checks all the rows above the formula’s row, where:
- the date within the 7 day range
- the driver name matches the name in 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.
=$C$1-D4+E4

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 the 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.
__________




Over the past few days, I’ve been without my desktop computer, which is on its way back to the repair shop.

