RE: Leave cell value untouched if Custom Function errors
From: Datasort (Datasort_at_discussions.microsoft.com)
Date: 10/28/04
- Next message: PO: "Referncing objects in spreadsheet"
- Previous message: Dan Thompson: "Retaining value of a string from a textbox on a form ??"
- In reply to: StephenBrook: "Leave cell value untouched if Custom Function errors"
- Next in thread: Tom Ogilvy: "Re: Leave cell value untouched if Custom Function errors"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 28 Oct 2004 09:33:06 -0700
You will need to put error testing into the function. something like ... on
error goto
Then you will need to test to make sure the error is a DB error. You can
find this out buy testing the Err.number.
in the error section set the function to equal n/a (or 0 if you are
returning a number)
Put an if or case statement to test with error:
if err.numer = ???? then
FunctionName = "N/A"
else
msgbox "Unknown error:" & err.decription
end if
Good Luck,
Stewart Rogers
"StephenBrook" wrote:
> I have a custom function that uses arguments from the user's worksheet to
> find data in an external Access database using ADO, then return it to the
> relevant cell. It works fine, but I want to be able to ensure that the custom
> function leaves the cell value *untouched* (rather than returning an error
> value) if the VBA cannot make the connection to the Access database (e.g. if
> the user can't access the database for some reason).
>
> I've tried using Application.Caller to get the cell's original value, but
> this doesn't seem to work. Can anyone help?
>
> Thanks,
>
> SB
- Next message: PO: "Referncing objects in spreadsheet"
- Previous message: Dan Thompson: "Retaining value of a string from a textbox on a form ??"
- In reply to: StephenBrook: "Leave cell value untouched if Custom Function errors"
- Next in thread: Tom Ogilvy: "Re: Leave cell value untouched if Custom Function errors"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|