Re: Returning text from Userdefined Functions
- From: "Zone" <KingOfWhiles@xxxxxxx>
- Date: Fri, 12 Oct 2007 05:17:07 -0400
VBA won't allow me to use the statement goto End, which doesn't surprise me.
If I change goto End to goto EndIt and change End: to EndIt: then the
function seems to work fine. James
"Mike H" <MikeH@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:26BE01D5-F140-436E-A823-C1C3D5548CCD@xxxxxxxxxxxxxxxx
Hi
Because the error handler is called from the UDF it is subject to the same
limitations as the UDF so if there's an error in the called routine you
aren't notified and simply get the VALUE error in the cell. Check out the
error handler it sounds very much like the error is within that.
Mike
"DagL" wrote:
This is the cell where the function is called from. Sometimes the string
is
returned correct, but when the code has been in an error handler, the
cell
displays "#VALUE!"
"Mike H" wrote:
A UDF cannot change any cell other than the one it is called from.
"DagL" wrote:
Hello!
I have a user defined function to write data back to a database in my
Excel
***. I return a smal text to show the user if the function was
successful
or not. When I set the return value of the function in regular code,
it works
fine. But, when something goes wrong, the execution goes to an error
handler,
the function does not return the string I set anymore.
I have the code:
Public Function WriteData()
on error goto ErrorHandler
.
.
calculations
.
.
WriteData = "OK" 'This is returned correct
to the
cell
goto End
ErrorHandler:
WriteData = "Not OK" 'This returns #VALUE to the
cell
End:
End Function
Can someone tell me the reason of this behavior, and/or what I am
doing wrong?
Regards DagL
.
- Follow-Ups:
- References:
- RE: Returning text from Userdefined Functions
- From: DagL
- RE: Returning text from Userdefined Functions
- From: Mike H
- RE: Returning text from Userdefined Functions
- Prev by Date: RE: Returning text from Userdefined Functions
- Next by Date: Re: Cell Update
- Previous by thread: Re: Returning text from Userdefined Functions
- Next by thread: Re: Returning text from Userdefined Functions
- Index(es):