In basic terms this UDF would perform the aforementioned array on an iterative basis - the iterations being determined by the number of rows within the initial Date range:
The "advantage" of the UDF is that in theory you could call from a cell, eg:
or, as I suspect you want to, you can invoke the Function from other Sub Routines passing parameter values appropriate to the data present at run time
Does that help at all ?
If you were prepared to hard wire some of the other references rather than pass all explicitly then you could obviously shorten the calls - that would be a call for you to make I think as it reduces flexibility
(note the code assumes vectors - M5:M8 rather than M5:N7 for ex. and that certain ranges reside on certain sheets - ie Actual, Nominal, Actual-TW1, MDays, S Difference all reside on same sheet)
I am somewhat irked by the fact that I've been unable to conjure a more elegant single cell method - I've not given up yet.
edit:
On a final note - I don't know as to whether or not the rows/columns are being physically deleted and replaced or not ...
In reality you could just set up some (non-volatile) dynamic named ranges and use those as the source ranges for an in cell UDF call in S8 - relatively straightforward, eg:
where_ActDates etc are dynamic ranges, eg:
note the constructs avoid volatiles like OFFSET etc and that height of each named range is determined by Column E for consistency
as data is added to E5 so the DNR's will adjust automatically and so the UDF result will recalculate.
Bookmarks