简体   繁体   中英

EXCEL: How do I count a pattern of values across multiple cells?

I have an attendance spreadsheet with values "OFF", "VAC", "HOL" and "SCK". I am trying to identify abuse of the SICK day policy where employees use their SICK days to extend their weekends, vacation or holidays. I would like to count the number of time these two text values are within four cells of each other in the same row a large range.

In this example, the count would yield an answer of "3" because there are 3 occurrences where the employee was SICK immediately before or after an "OFF" day.

Is this possible in a formula?

It's hard to tell from your picture how many cells are involved, is "SCK" on 24th 4 cells after "OFF" on 23rd?

If so try using a COUNTIFS function with the ranges offset by 4 cells, eg

=COUNTIFS(A1:Z100,"OFF",E1:AD100,"*SCK")

adjust ranges as required

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM