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:
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:
<tbody>
</tbody>
Any help/suggestions would be greatly appreciated.
Kind Regards
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
Mon | Tue | Wed | Thu | Fri | Single | Consecutive | Helper |
s | s | s | 1 | Yes | |||
s | s | 1 | 3 | No | |||
s | s | s | 1 | 2 |
<tbody>
</tbody>
Any help/suggestions would be greatly appreciated.
Kind Regards