View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
DagL DagL is offline
external usenet poster
 
Posts: 10
Default Returning text from Userdefined Functions

Hello!

I have a user defined function to write data back to a database in my Excel
sheet. 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