|
|
|
UDF Untrapped Error in Excel 97
|
| This only happens within Excel 97. The problem has been
corrected in Excel 2000 onwards. |
|
| When running code it might stop unexpectedly without any
obvious cause. No error messages will be displayed and no warning given
that an error is about to occur or has occurred. |
|
udf_untrapped_error.zip |
|
| The instructions on how to recreate the error are shown
below. These are repeated in the example's VBA module. |
|
- Ensure the immediate window is open so you can see the output from
Debug.Print.
If it is not open press Ctrl+G
- Run the sub "UdfUntrappedErrorDemo".
Notice you get two messages in the immediate window and that the
cell with range name "DateAndTime" has had its contents updated.
- Go to the worksheet. Change the argument to the light green cell
from:
REVNUM("udf_untrapped_error.xls")
to
REVNUM("Xudf_untrapped_error.xls")
This will cause the formula to report a "#VALUE!" result.
- Rerun the sub "UdfUntrappedErrorDemo".
Notice that you only get the first message.
This is because Excel encounters the error, when running its
formula recalculation engine, and stops.
- Uncomment the error trap in the REVNUM function, below.
- Rerun the sub "UdfUntrappedErrorDemo".
You now get both messages.
The trap tells Excel how to cope with the error.
|