The logic seems sound enough to me - apologies for the oversight on my part regards the perpetual project issue.
I would be wary of using the UDF en masse simply because it isn't a particularly light weight function given use of Dictionary Object.
You should be aware that whenever any of the precedents are altered - ie:
enrollers3
start
end
compartive date (adjacent cell to UDF result)
every single cell utilising the UDF will be flagged as requiring recalculation.
It follows that on Auto Calc the calculation time will be significant should you have lots of calls to the UDF.
You will notice this lag when opening the file -- given the "today" cell is updated this in turn affects the "end" range and therefore flags the UDF's as requiring a recalc.
The above is both expected & correct (the UDFs do require recalculation as and when that value changes), however, it is just something to be aware of.
If you find you want to leave the file on Auto Calc but wish to control as and when the UDFs all recalculate you can add a pre-emptive IF to each UDF call based on say a "flag".
Using your sample file - let's assume:
-- UDFs in Col B have been removed (legacy UDF)
-- E1 on Summary sheet contains either 0 or 1 where 1 means UDFs should calculate and 0 means they should not.
We can modify the in-cell call to:
C2:
=IF($E$1=0,"to be calculated",UNIQUEHC2('7.6'!enrollers3,'7.6'!start,'7.6'!LEFT,'7.6'!end,$A2))
copied down
We will now find that if we set E1 to 0 and subsequently modify the precedent ranges the UDFs do not recalculate even if we're running Excel in Auto Calculation mode.
If we then change E1 to 1 from 0 then the UDFs will all recalculate.
Not an ideal setup but pending the frequency with which you modify the precedent ranges (I'm thinking specifically of enrollers3) you might find it's worthwhile implementing.
In reality the viability of the above all rather depends on the workflow down the line and how critical these numbers are in the overall operation of the model.
Bookmarks