One solution would be to change the number 40 to the number of the last row, 1048576 for the 2019 version, so that the formula for cell D6 will be:
Formula:
=IF(ISNA(MATCH($A6&D$4,Info!$P$2:$P$91,0)),IFERROR(INDEX(MarkLeave!$G$2:$G$1048576,AGGREGATE(15,6,(ROW(MarkLeave!$G$2:$G$1048576)-ROW(MarkLeave!$G$1))/(MarkLeave!$B$2:$B$1048576=$B6)/(MarkLeave!$D$2:$D$1048576<=D$4)/(MarkLeave!$E$2:$E$1048576>=D$4),1)),""),"BH")
However, this will probably produce a significant lag in calculations.
Another solution would be to convert the data range on the Mark Leave sheet into a table only containing rows that are currently filled. When a new row is added to the table the formula will update.
If you choose this option then before adding another row to the table, select cell D6 and then paste this formula into the formula bar:
Formula:
=IF(ISNA(MATCH($A6&D$4,Info!$P$2:$P$91,0)),IFERROR(INDEX(MarkLeave!$G$2:$G$4,AGGREGATE(15,6,(ROW(MarkLeave!$G$2:$G$4)-ROW(MarkLeave!$G$1))/(MarkLeave!$B$2:$B$4=$B6)/(MarkLeave!$D$2:$D$4<=D$4)/(MarkLeave!$E$2:$E$4>=D$4),1)),""),"BH")
Note that Gino was added to the table after the formula was changed.
Let us know if you have any questions.
Bookmarks