I think another way to go is to not try to build an application. If you can do the calculation using worksheet functions you might well find that the spreadsheet becomes more portable (less security) and more maintainable (no source code).
what you seem to be asking for is an indication of the number of times the subset of numbers changes.
If your column (Ax:Ay) contains your set of values.
The total number of sick days is easy:
"=SUM(Ax:Ay)"
The total number of changes can be derived by using an adjacent column, or a column in another worksheet if you prefer. I'll use the adjacent column.
in each cell put this:
=IF(AND(An<>A(n-1),Bn=0),1,0)
where An is the cell to the left and A(n-1) is the cell northwest.
then put a zero as the first item in column A and the last item in column A so you have an interface to count. put the expression at the bottom of column B (ie at cell y+1) and sum column B
=SUM(B(x-1):b(y+1))
So your worksheet looks like this (assume the first row is 1):
- Code: Select all
Column A Column B
___________________
1 | 0
2 |1 =IF(AND(A2<>A(1),B2=0),1,0)
3 |1 ...
4 |1
5 |0
6 |0
7 |0
8 |1
9 |0
10|1
11|1
12| 0
13|=sum(A) =SUM(B)