Counting consecutive values

kyddrivers

Board Regular
Joined
Mar 22, 2013
Messages
59
Office Version
  1. 365
Platform
  1. Windows
I am trying to figure out a way to count the days worked in between days off in a 2 week period.

I have a column for each of the days of the week, in those columns reflect the start time if they are working or Off if they are off for that day.

The formula I tried in column S is: =MAX(FREQUENCY(IF(E2:R2<>"off", MATCH("~"&E2:R2, E2:R2&"",0)), ROW(E2:R2)))

Column T is the value that I need.

COL EFGHIJKLMNOPQRST
SunMonTueWedThuFriSatSunMonTueWedThuFriSatValuesShould Be
off12:00 AM12:00 AM12:00 AM12:00 AM12:00 AM12:00 AM12:00 AM12:00 AM12:00 AM12:00 AM12:00 AM12:00 AM12:00 AM1213
12:00 AMoffoff1:00 AM1:00 AM1:00 AM12:00 AM2:00 AMOffOff2:00 AM2:00 AM2:30 AM2:00 AM95

<tbody>
</tbody>

Any help that can be provided is greatly appreciated as I have over 500 lines I need to do this calculation on.

Thanks in advance.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Control+shift+enter, not just enter, and copy down:

=MAX(FREQUENCY(IF(ISNUMBER(E2:R2),COLUMN(E2:R2)),IF(E2:R2="off",COLUMN(E2:R2))))
 
Upvote 0
Solution
In kyddrivers example, how would you total the number of times a cell is not blank and count consecutive non-blank cells as 1? Using the last row as an example and assumed that all values of "off" were replaced by a blank, I would want a total count=3, since E3 is not blank, H3-L3 is not blank, and O3-R3 is not blank.
 
Upvote 0
In kyddrivers example, how would you total the number of times a cell is not blank and count consecutive non-blank cells as 1? Using the last row as an example and assumed that all values of "off" were replaced by a blank, I would want a total count=3, since E3 is not blank, H3-L3 is not blank, and O3-R3 is not blank.

Control+shift+enter, not just enter:

=SUM(IF(FREQUENCY(IF(ISNUMBER(E3:R3),COLUMN(E3:R3)),IF(E3:R3="",COLUMN(E3:R3))),1))
 
Upvote 0
As you expected, it worked beautifully! Thank you. As a follow-up, can this formula remain active if applied to a pivot table?
 
Upvote 0
Thank you Aladin for your helpful responses. In selecting various filters on my pivot table, the calculations based on the formula is shifted to the far right. Can this be moved to the left based on the filters or is it because of the reference ranges? Another thought is...if it's possible to do the calculation after the filters are selected.
 
Upvote 0
Thank you Aladin for your helpful responses. In selecting various filters on my pivot table, the calculations based on the formula is shifted to the far right. Can this be moved to the left based on the filters or is it because of the reference ranges? Another thought is...if it's possible to do the calculation after the filters are selected.

It's hard to assess the situation without having the pivot table, I'm afraid.
 
Upvote 0

Forum statistics

Threads
1,216,213
Messages
6,129,552
Members
449,516
Latest member
lukaderanged

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