Function my Sum1(Sheet Name as string) as Variant my Sum1=Worksheets(Sheetname). Range("A2") End Function This function will not automatically recalculate if Data!
A2 changes: it will only automatically recalculate when Sheetname changes.
Un-trapped errors can halt the calculation process before it is complete.
Function my Sum4(the First Cell as range,the Second Cell as range) as Variant On error goto Func Fail: my Sum4=thefirst Cell.
If this happens you may need to explicitly recalculate your function.
For optimum performance UDFs should be coded in C and use the C API.
Because UDFs referenced by conditional formatting will be executed more frequently than you would expect it is not a good idea to reference slow-running UDFs from conditional formats.
If you don't have an On Error handler in your UDF you may need to be aware of the differences in the way that different Excel versions react.
What this means is that the function will only be flagged as needing evaluation when one or more of the input arguments change (unless the function is volatile).This means that the UDF may give incorrect answers without warning.I recommend that you do not attempt to program a UDF to handle multi-area ranges as arguments: use multiple (optional if there are a varying number) range arguments instead.Value the Second Cell.value Exit Function Func Fail: my Sum4=Cv Err(xl Err Value) End Function UDFs referenced in conditional formats get executed each time the screen is refreshed (even if Application.screenupdating=false), and breakpoints in these UDFs will be ignored.Make sure you have an On Error handler in all UDFs referenced in conditional formats, since unhandled errors during a UDF execution caused by a screen refresh may cause VBA to silently stop running without any error message being issued.