I don't have access to Excel, so I really am not in a position to debug this for you. Did you try setting a break point on the function statement so you could enter break mode? At this point, we need to identify which statement is creating the error, which will be easiest from within break mode.
Another strategy I have used is to comment out all of the computations except the first one. Then set the function to return this computation. If the function works as expected, then add the second statement (updating the return value to the most recent calculation), and continue adding statements until the statement creating the error get added. This looks like
Bookmarks