If you just use this part....
=MIN(EOMONTH(F$1,0),D2)-MAX(F$1,C2)+1
You will get some negative results where the C2-D2 range doesn't intersect with that month at all, so MAX with zero means that all the negative results are converted to zeroes
Note: I edited my earlier post to include a solution which gives your original table without individual results for each row
Bookmarks