Thanks; yes, it's Volatile too (given use of INDIRECT) -- so I wouldn't be arguing it should be used...
I just found the challenge interesting... and spent way too long that is acceptable trying to work out a suitable approach... in the end it's relatively straightforward logic:
- create an array of values for all preceding rows such that the end date serial is appended as a decimal remainder of the associated label value
- from the above array extract the "max" value for each label
- above achieved via an outer SMALL in conjunction with a dynamic k array, the k array being determined by a COUNTIF relative to any / all labels used to that point
- the date serial values can be removed from the SMALL results c/o MOD leaving just the date "decimal", in turn reverted to a date serial (c/o * and round)
- the final test is then to see which is the first label with a current end date preceding the criteria (c/o MATCH) and use that as the result
- if there is no such result a new label must be required (determined as max of preceding labels + 1)
Note:
I realise now, having typed out the above, that my final test is incorrect as it is testing the end date rather than the start date of the current row, and thus should in fact read:
change being first cell reference now reads $B4 as opposed to $C4, remainder unchanged...
just so happens that with the sample data you get the same results, either way ;-)
Bookmarks