Count cells in row (range) with a value that are not consecutive

jjones312

New Member
Joined
May 17, 2013
Messages
36
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I have a spreadsheet that calculates employee absences and tardiness. There is a policy rule that if the absence is back-to-back, it only counts as a single occurrence. Currently I'm using "=COUNTIF(January[@[1]:[31]],"US")" to count all cells in a row that contains "US". Now I need to apply the policy piece.

Here is an example:
Row 1: Has entries for "US" twice on non-consecutive days. This should total in the column "US", column AK as 2 occurrences.
Row 2: Has three entries for "US" back to back, consecutive days. This should only count as 1 occurrence.
Row 3: Has four entries for "US" back-to-back and non-consecutive days. This should add up to three occurrences.

Can anyone assist in the formula for this? I'm at a lost at the moment.
 

Attachments

  • Screenshot 2023-01-10 154054.png
    Screenshot 2023-01-10 154054.png
    22.7 KB · Views: 19
It is deliberately offset, that way in checks if B4=US & if A4 <>US to see if the cell to the left contains US or not.
FYI..

It works perfectly on teams with the formula, and the supervisors are so STOKED!!!! Thank you
 
Upvote 0

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,223,909
Messages
6,175,315
Members
452,634
Latest member
cpostell

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