JenniferMurphy
Well-known Member
- Joined
- Jul 23, 2011
- Messages
- 2,691
- Office Version
- 365
- Platform
- Windows
If Function A is called from an Excel cell and then calls Sub B, is there any way that B can return an error condition directly back to the Excel cell on behalf of A without returning control to A?
I am working on a UDF (A) that does a lot of error checking. Wanting to standardize the error handling, I wrote an error handling procedure (B). A calls B, which does the error checking and returns True if it found an error or False if not.
Here's an example of the code in the main UDF and a snippet of the sub-function.
I would like to change that to something like this:
Is some code that I can put in the B that will do this?
Thanks
I am working on a UDF (A) that does a lot of error checking. Wanting to standardize the error handling, I wrote an error handling procedure (B). A calls B, which does the error checking and returns True if it found an error or False if not.
Here's an example of the code in the main UDF and a snippet of the sub-function.
Code:
. . .
If B(p1, p2, ...) then A = CVErr(xlErrValue): Exit Function
. . .
Public Function B(p1, p2, ...) as Boolean
ErrorFun = False
. . .
If (some error condition exists) then B = True: Exit function
. . .
Code:
. . .
Call B(p1, p2, ...) 'Do some error checking
. . .
Public Sub B(p1, p2, ...)
. . .
If (some error condition exists) then
??? return an error condition to the Excel cell that called A (not to A itself) ???
End If
Is some code that I can put in the B that will do this?
Thanks