Hi All
I have a wee problem with an Exel UDF.
The function is used in a cell in the spreadsheet typically just
= payrate(C8,E8,$E$5 - $D8)
and generally works fine
But when I edit the cell with the function (in the simplest case, F2 and enter) the function code is then evaluated twice.
For the first evaluation, one of the parameters (a calcuated value) is 0 despite having a valid value visible in the cell - the other two are correct but they are constants not formulae
.
I presume the second evaluation happens because, at some stage after the first evaluation, the calculated parameter is recalculated (no idea why) and this triggers a second calculation of the UDF
But why does excel use 0 for the first calculation when there is a perfectly good value visible in the cell? it wouldn't matter greatly except that it triggers a bunch of msgbox errors
And a minor irritation: Towards the end, the function is set with Payrate = Round(mres,2)
But when the result is displayed on the worksheet it can be something like 8.909999847
whereas I thought round should make it 8.91
Thanks for any suggestions
With apologies for the poor quality, the UDF follows:
Bookmarks