find time average from columns after countif finds the columns

sbeuk

New Member
Joined
Sep 18, 2015
Messages
15
Hi,

Driver Sheet Monday
abcdefghij
112344765444644376542125679853412578275338562106345
2abcbabcbhijkabnocbrs
3
416:3516:1517:0116:5018:0017:5017:3518:0517:3018:07
517:0016:4517:3017:2518:3518:3018:0018:4018:0018:45

<tbody>
</tbody>

Driver Summary, separate sheet)
driver: ABNumber cars/dayaverage time/day (mins)
mon532:23
tue621:12
wed345:23
thu830:12
fri134:12

<tbody>
</tbody>

I have drivers (initials, row 2) out each day, in various vehicles (vin Numbers, row 1), and clock their in and out times - rows 4 and 5.
I would like to create a summary for each driver that details how many times a day they've been out, and their overall average time on the road over a week.
I managed to use CountIf to look across row 2 of the top sheet for the different initials which allowed me to summarise how many vehicles each driver had taken out, and could use the data from one drivers' column to get how many minutes he was out, then I was stumped as to how to ask the Sheet to look at the times from all the occurrences of any given drivers' initials to sum up the times!

I hope this has made some sense, and please forgive me for any daft questions or lack of understanding. I assure you that any shortcomings will be mine.

Thanks in advance.

Regards,

sbe
 
Last edited:

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
I would use a SUMPRODUCT formula. Let's assume the rows end in column J.
=SUMPRODUCT((A2:J2 = Driver) * (A5:J5 - A4:J4))

Driver would be a cell that contains the driver's ID.

(A2:J2 = Driver) – an array of TRUE and FALSE values

(A5:J5 - A4:J4) – The second array: end times minus start times

* – Multiplication coerces TRUE and FALSE to the integers 1 and 0. Each value in the first array gets multiplied by the corresponding value in the second array. The result of these multiplications will also be an array.

SUMPRODUCT() – Calculates the sum of the array created by the multiplication

Hope this helps.
 
Upvote 0
Hi,

Thank you for your reply.

I put your formula, thus:

=SUMPRODUCT((monday!B10:AG10 = "ab") * (monday!B13:AG13 - monday!B12:AG12)) - for monday, then
=SUMPRODUCT((tuesday!B10:AG10 = "ab") * (tuesday!B13:AG13 - tuesday!B12:AG12)) - into tuesday and so on for that persons' week, but I just got "#VALUE!" error?

I'm sure my error will cause mirth, but this is rather new to me, so please excuse my ignorance.

Kind regards,

sbe


 
Upvote 0
Hi,

Thank you for your reply.

I put your formula, thus:

=SUMPRODUCT((monday!B10:AG10 = "ab") * (monday!B13:AG13 - monday!B12:AG12)) - for monday, then
=SUMPRODUCT((tuesday!B10:AG10 = "ab") * (tuesday!B13:AG13 - tuesday!B12:AG12)) - into tuesday and so on for that persons' week, but I just got "#VALUE!" error?

I'm sure my error will cause mirth, but this is rather new to me, so please excuse my ignorance.
I'm not cracking a smile, I hate when I have to chase error results from a formula.

The most likely cause of the #VALUE! error is a cell, or several cells, in monday!B12:AG13 that cannot be interpreted as a number: cells containing text.

This next formula may work. It's an array formula, and must be entered using Ctrl+Shift+Enter, instead of a plain Enter. If done correctly, curly braces, '{' and '}', will enclose the formula.

=SUMPRODUCT((monday!B10:AG10 = "ab") * (IFERROR(monday!B13:AG13 - monday!B12:AG12, 0)))

The SUMPRODUCT function is designed to work with arrays. IFERROR is not designed to do so and must be forced to be an array formula with Ctrl+Shift+Enter. If the curly braces do not appear, the results will still be a number but it will probably not be a correct number.
 
Upvote 0
Oh my goodness! That's it!
It produced a decimal number, wondered what had happened, then realised I may need to format the cells as time, and it appears to be working with my dummy data :)
Huge thanks, I will let you know how it works on the 'live' sheet'
Incredibly grateful for your help.
Respect.
Best regards,
sbe
 
Upvote 0
As promised - update - works beautifully with the live data. Thank you.

I've been asked to add a feature: When a driver goes out, sometimes their vehicle has a problem, this is highlighted by changing the relevant cell colour A, B, C etc to red. How could I ask the sheet to look at the A, B, C.... row, and if it is red, put the VIN number (row 1) in a table on a new sheet?
I changed the SUMPRODUCT formula to look at the relevant rows, but got stumped when I realised it had to check a cell colour, rather than a value.

Thanks in advance.

Best regards,

Sbe
 
Upvote 0
As promised - update - works beautifully with the live data. Thank you.

You're welcome.

For your next question, there is no builtin Excel function to determine a cell's fill color. I'm no more than a novice at VBA. Let us hope some other forum user will offer a solution.
 
Upvote 0

Forum statistics

Threads
1,216,028
Messages
6,128,399
Members
449,446
Latest member
CodeCybear

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