Count consecutive sick leave

hainer76

New Member
Joined
Jan 6, 2014
Messages
5
Hope you all are doing well

I have managed to put together a sick leave tracker in excel. (Might hopefully in part or as a whole be useful to someone.)
Some time ago I found two methods for counting consecutive cells with the same value in a row.
Unfortunately I do not remember the original poster/s but all credit where it's due. I have modified the formulas to check for 4 and 5 consecutive counts as well in (Method1) and the same for the array option in (Method2).

The worksheet:
  • a seperate sheet for each employee covering 52 weeks (row 2 to row 53)
  • public holidays do not get counted (added these in a named range)
  • each week (one row) divided up into days of the week (column E to I)

Method1:
ex. The formulas in cells K2 to P2
"s"
is entered into a cell when the day is taken as sick leave (column E to I)
K2 - helper column with "text string"
=IF(E2=""," ","s")&IF(F2=""," ","s")&IF(G2=""," ","s")&IF(H2=""," ","s")&IF(I2=""," ","s")
L2 - checking fr single days
=(LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(O2,"sssss",""),"ssss",""),"sss",""),"ss",""))-LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(O2,"sssss",""),"ssss",""),"sss",""),"ss",""),"s","")))
M2 - checking for 2 consecutive days
=(LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(O2,"sssss",""),"ssss",""),"sss",""))-LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(O2,"sssss",""),"ssss",""),"sss",""),"ss","")))/2
N2
- checking for 3 consecutive days=(LEN(SUBSTITUTE(SUBSTITUTE(O2,"sssss",""),"ssss",""))-LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(O2,"sssss",""),"ssss",""),"sss","")))/3
O2
- checking for 4 consecutive days
=(LEN(SUBSTITUTE(O2,"sssss",""))-LEN(SUBSTITUTE(SUBSTITUTE(O2,"sssss",""),"ssss","")))/4
P2
- checking for 5 consecutive days
=IF(COUNTIF(E2:I2,"")<1,1,"")
Method2:

same basic setup as in Method1 but using array formulas
- checking for 2 consecutive days
{=SUM(IF(FREQUENCY(IF(E2:I2="s",COLUMN(E2:I2)),IF(E2:I2<>"s",COLUMN(E2:I2)))=2,1))}

- checking for 3 consecutive days
{=SUM(IF(FREQUENCY(IF(E2:I2="s",COLUMN(E2:I2)),IF(E2:I2<>"s",COLUMN(E2:I2)))=3,1))}

- checking for 4 consecutive days
{=SUM(IF(FREQUENCY(IF(E2:I2="s",COLUMN(E2:I2)),IF(E2:I2<>"s",COLUMN(E2:I2)))=4,1))}

- checking for 5 consecutive days
{=SUM(IF(FREQUENCY(IF(E2:I2="s",COLUMN(E2:I2)),IF(E2:I2<>"s",COLUMN(E2:I2)))=5,1))}

This all works great. The problem I now face is the following. A working example, ex. employee named Pete.

Pete has taken Monday off sick, the Friday off sick in the same week and the Monday and Tuesday in the following week.
In this example the first row(Mon/Fri) formulas would evaluate to two single days of sick leave and the second row(Mon/Tue) to two consecutive days.
What I would like to happen is the first row to evaluate to one day (Mon) and the second row to evaluate to three consecutive days (Fri/Mon/Tue).

So what I would really appreciate help with is the following:
  • if a Friday is taken as sick leave check if it is part of consecutive days of leave, i.e. (Thu/Fri or Wed/Thu/Fri)
  • check if the following Monday is taken as sick leave
  • if one or both of the criteria is met add the Friday to the following week
  • any non-consecutive days are recorded in the relevant rows

MonTueWedThuFriSingleConsecutiveHelper
sss1Yes
ss13No
sss12

<tbody>
</tbody>

Any help/suggestions would be greatly appreciated.

Kind Regards
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
DRSteele

Many thanks for the reply.
I have never used HTML maker before.
I have Excel 2010 and 2013.
The add-in is activated in both, the menu options are available on right-click and in the drop down menu on the ribbon.

I have tried the default and all formulas options.

On pasting the selection into the editor I eventually get the small "Kill Pages / Wait" pop-up window.
If I select wait the "editor", this window, is filled with what appears to be web page code.
Does that mean the selection was successfully loaded?

Are you open to any other methods?
Windows SkyDrive or direct email?
I do apologise for any inconvenience caused.
Any help would be greatly appreciated.
Kind Regards
 
Upvote 0
Yes, that web-codey-lookin stuff is alright --- it's then loaded. Press Go Advanced and Preview post and you'll see what your post will look like. Then when it's OK press Submit Reply.
 
Upvote 0
Edit: Too slow was same response as post #4.....Deleted
 
Upvote 0
Many thanks DRSteele and MARK858. Worked in Excel 2010 selecting "Default".
Please note the sheet includes both the methods I found on this site.
I am open to any suggestions to which might be better avoiding VBA regardless.

Excel 2010
BCDEFGHIJKLMNOPQRS
1WeekSaturdaySundayMondayTuesdayWednesdayThursdayFriday2 consecutive Sick Days3 consecutive Sick Days4 consecutive Sick Days5 consecutive Sick Days1 Day Sick2 Days Sick3 Days Sick4 Days SickOne Week
21sss1000s ss1100
32sss0100 sss0010
43s0000 s1000
54ssss2000ss ss0200
65s0000 s1000
76ss1000 ss0100
87sss0000s s s3000
98sss1000s ss1100
109sssss0001sssss00001
1110ss0000s s2000
121100000000
131200000000
141300000000
151400000000

<tbody>
</tbody>
Sheet2



Excel 2010
BCDEFGHIJKLMNOPQRSTUVWX
17Formulas in J2 to M15 =SUM(IF(FREQUENCY(IF(E2:I2="s",COLUMN(E2:I2)),IF(E2:I2<>"s",COLUMN(E2:I2)))=2,1)) =SUM(IF(FREQUENCY(IF(E2:I2="s",COLUMN(E2:I2)),IF(E2:I2<>"s",COLUMN(E2:I2)))=3,1)) =SUM(IF(FREQUENCY(IF(E2:I2="s",COLUMN(E2:I2)),IF(E2:I2<>"s",COLUMN(E2:I2)))=4,1))
18Formulas in N2 to N15 =IF(E2=""," ","s")&IF(F2=""," ","s")&IF(G2=""," ","s")&IF(H2=""," ","s")&IF(I2=""," ","s")
19Formulas in O2 to O15 =(LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(O2,"sssss",""),"ssss",""),"sss",""),"ss",""))-LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(O2,"sssss",""),"ssss",""),"sss",""),"ss",""),"s","")))
20Formulas in P2 to P15 =(LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(O2,"sssss",""),"ssss",""),"sss",""))-LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(O2,"sssss",""),"ssss",""),"sss",""),"ss","")))/2
21Formulas in Q2 to Q15 =(LEN(SUBSTITUTE(SUBSTITUTE(O2,"sssss",""),"ssss",""))-LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(O2,"sssss",""),"ssss",""),"sss","")))/3
22Formulas in R2 to R15 =(LEN(SUBSTITUTE(O2,"sssss",""))-LEN(SUBSTITUTE(SUBSTITUTE(O2,"sssss",""),"ssss","")))/4
23Formulas in S2 to S15 =IF(COUNTIF(E2:I2,"")<1,1,"")

<tbody>
</tbody>
Sheet2
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,552
Members
449,088
Latest member
davidcom

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