Forum Discussion
Adding to a formula
So I might suggest re-doing the whole formula because it appears to have parts you just don't need
Let's first break down what you have:
Holiday bkd and Holiday taken appear to the the exact same except 'taken' is BEFORE the date in A1 and 'bkd' is AFTER the date in A1
Presumably, you have dates from 1/1 (cell A13) to the end of the year 12/31 (cell A377)
I'm not sure but I'm guessing that 'SetUp Tab'!$E$6 is if this year is a leap year and you need to include A378
So instead of an IF statement and repeating the same formula but adding row 378 just include 378 and leave it blank if it is not a leap year.
Also, since the dates are going up from 1/1 to 12/31 you don't need to check if >= 1/1 or <= 12/31
so what you need is a reference to the range of value either from 1/1 to the date in A1 or from the day after A1 to 12/31. This can be achieved using:
Q13:INDEX(Q13:Q378, A1-DATE(YEAR(A1),1,0))
so having that range we can then simple do a compare and SUM like this for 'taken':
=LET(rng, Q13:INDEX(Q13:Q378, A1-DATE(YEAR(A1),1,0)),
SUM((rng="H")-(rng="L")+0.5*(rng="PH)) )and then for 'bkd':
=LET(rng, INDEX(Q13:Q378, A1-DATE(YEAR(A1),1,0)):Q378,
SUM((rng="H")-(rng="L")+0.5*(rng="PH)) )