Highlight days in a row from vertical lists

Johana H

New Member
Joined
Mar 14, 2017
Messages
5
Hi there,
I have a spreadsheet that includes the dates and Number of days the employees have been taking sick leave in the last year. The information is shown as per the following table:

Full NameLeave Start DateLeave End DateUnits Taken
Maria8/09/20168/09/20166
Maria7/12/20167/12/20167.5
Maria8/12/20168/12/20166
Maria10/12/201610/12/20166.5
Joe21/03/201621/03/20167.5
Joe22/03/201622/03/20167.5
Joe24/03/201624/03/20165.75
Jenny17/08/201617/08/20167.5
Jenny18/08/201618/08/20167.5
Anna8/04/20168/04/20167.6
Anna18/04/201618/04/20167.6
Lee22/01/201622/01/20161.5
Lee7/04/20167/04/20164.6

<colgroup><col><col><col><col></colgroup><tbody>
</tbody>


At this stage, I need to highlight the consecutive days that an employee has been requesting sick leave. As the aim is to identify who is taking days in a row.

I have been trying to use the conditional formatting à New rule à use a formula, with the following formula:
=(COUNTIF($B$3:$B$500,B3+1)+COUNTIF($B$3:$B$500,B3-1))>0

However, is not working.

Thanks for your help
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Welcome to the Board!

Let's say that your data is in columns A-D, and starts on row 2.
Then select the range you want to apply this Conditional Formatting to, starting in row 2, and use this CF formula:
Code:
=OR(AND($A2=$A3,$C2+1=$B3),AND($A2=$A1,$C1+1=$B2))
 
Upvote 0
Thank you! It works.

I also need to count how many days in a row a person has taken. I've been applying the following formula (using the same example and an additional table with the employee's name), but when I applied for my spreadsheet with nearly 12.000 records is not accurate.

I have applied this formula =SUMPRODUCT(($C$3:$C$15=$K3)*($D$4:$D$16-$D$3:$D$15=1))+(COUNTIF($C$3:$C$15,$K3)>0)

Sheet 1 A BCDSheet 2KL
Full NameLeave Start DateLeave End DateUnits Taken2NameNo. of days in a row
1Maria8/09/20168/09/201663Maria
2Maria7/12/20167/12/20167.54Joe2
3Maria8/12/20168/12/201665Jenny2
4Maria10/12/201610/12/20166.56Anna
5Joe21/03/201621/03/20167.57Lee
6Joe22/03/201622/03/20167.5
7Joe24/03/201624/03/20165.75
8Jenny17/08/201617/08/20167.5
9Jenny18/08/201618/08/20167.5
10Anna8/04/20168/04/20167.6
11Anna18/04/201618/04/20167.6
12Lee22/01/201622/01/20161.5
13Lee7/04/20167/04/20164.6

<colgroup><col><col><col><col><col><col><col span="4"><col></colgroup><tbody>
</tbody>

<colgroup><col><col><col><col><col><col><col span="4"><col></colgroup><tbody>
</tbody>

Any ideas? or there is other way to count the number of days in a row they have taken.

Thanks :)
 
Upvote 0
Hi Johana - not sure if I will be able to help with the actual formulas you want but I have a couple of questions for you - the question may be a bit more complex than as you originally asked

1. You are looking for employees for have "days off in a row" . Are you only concerned if the "days off" are consecutive calendar days ? Your question and Joe4's answer don't pick up if Fred had Friday 3/3/17 off and was also absent on Monday 6/3/17 but if he is a Monday to Friday employee then he did have "days off in a row"

2. you want to know how many total "days off in a row" . in your sample data each person only has one "lot of consecutive days" off. so not too hard. But in my data below Maria has a second lot of "days off in a row" (3 days in a row in March)
I think you might want to know the number of days off for each instance not just total her "days off in a row" as 5

Full NameLeave Start DateLeave End DateUnits Taken
Maria8/09/20168/09/20166#VALUE!startenddays
Maria7/12/20167/12/20167.5TRUEMaria7/12/20168/12/20162
Maria8/12/20168/12/20166TRUEJoe21/03/201622/03/20162
Maria10/12/201610/12/20166.5FALSEJenny17/08/201618/08/20162
Joe21/03/201621/03/20167.5TRUEMaria1/03/20173/03/20173
Joe22/03/201622/03/20167.5TRUELee
Joe24/03/201624/03/20165.75FALSEAnna
Jenny17/08/201617/08/20167.5TRUE
Jenny18/08/201618/08/20167.5TRUE
Anna8/04/20168/04/20167.6FALSE
Anna18/04/201618/04/20167.6FALSE
Lee22/01/201622/01/20161.5FALSE
Lee7/04/20167/04/20164.6FALSE
Maria1/03/20171/03/20178TRUE
Maria2/03/20172/03/20178TRUE
Maria3/03/20173/03/20178TRUE
Joe3/03/20173/03/20171FALSE
Joe6/03/20176/03/20178FALSE

<colgroup><col><col><col><col><col span="3"><col><col><col span="2"></colgroup><tbody>
</tbody>
 
Upvote 0
Hi Liveinhope,
Thanks for your quick response.

Your example is just what I need, I was thinking on a way to make it easier, but the way you are presenting the information looks pretty straight forward, as some employees have several lots of consecutive days that I still need to identify.

Regarding to your question the majority of the employees work with roster (I'm able to identify who has roster or not), which would make this harder as they have sometimes 2 separate days off, during the weekdays. If I would apply the example you stated about Fred being absent Friday 3/3/17 and Monday 6/3/17 then he'd have "days off in a row".

I know is a bit complex but I guess including another column with joe's formula =OR(AND($A2=$A3,$C2+2=$B3),AND($A2=$A1,$C1+2=$B2)), would help to identify the employees that may have taken sick days before and after their day off.

Thanks for your help :)
 
Upvote 0
unfortunately it's not simple ..

To make it a bit simpler lets pretend that your employees all work Monday to Friday only (so we don't need to look at individuals rosters) and just start off with the "highlight rows where employee has 2 days off I a row" to start

(Come back to the summary part later . that bit's a bit beyond me .)

If you use this formula instead of the one originally from Joe4 =OR(AND($A2=$A3,WORKDAY($C2,1)=$B3),AND($A2=$A1,WORKDAY($C1,1)=$B2)) will highlight where someone had Friday and the following Monday off
But it wont pick up if employee has Friday off, Monday is a public holiday and they also have Tuesday off

To do that you would need a table of public holidays on sheet2 and use this formula =OR(AND($A2=$A3,WORKDAY($C2,1,Sheet2!$A$2:B$20)=$B3),AND($A2=$A1,WORKDAY($C1,1,Sheet2!$A$2:$A$20)=$B2))

(and then you are still limited by my first design rule "Monday to Friday are workdays , Saturday and Sundays are days off".. Someone who has a rostered Saturday off is not identified
 
Upvote 0
Thanks! the formula works perfect for employees that work Mon-Fri.

I would really appreciate if you could help me with the summary.

Thanks again!
 
Upvote 0
Sorry but the summary bit is beyond me ... I'm pretty sure it will require a VBA solution . Fingers crossed someone who can help there (maybe Joe4 as he's already responded to this thread ) will help out !
I'll be watching because I'd like to know how to do this too

(Ideally you should compare days off against each individuals schedule rather then just treat them all as "wrok Mon-Fri , Sat - Sun off")
 
Upvote 0
I also need to count how many days in a row a person has taken.
That really is a whole another question entirely, and different from your original question.
And as liveinhope mentioned, it is no easy task. It is much more difficult than your original question.
To do it with native Excel functions is beyond my formula capabilities. I would probably try to attack it from a VBA standpoint.
 
Upvote 0
Thanks for your help. As the spreadsheet is complex I was going step by step to get the report I needed. The first part was identifying then create the report.

All the information has been very helpful. thanks.
 
Upvote 0

Forum statistics

Threads
1,216,045
Messages
6,128,484
Members
449,455
Latest member
jesski

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