Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Trigger a Error from a VBA function

Tags:

excel

vba

I need to trigger(return) an error event from a VBA function, then the calling function of this function can trigger On Error Go to call. E.g

function Test()
 On Error Go to myError:
       TestErr()
 Exit Function

 myerror:
    Test = "Error Triggered"
End Function

Function TestErr()
    ?? 'How to Trigger error here
End Function

Thank You

like image 570
nimo Avatar asked Jun 16 '10 06:06

nimo


1 Answers

Err.Raise 5, "optional error source" , "optional error description"

MSDN reference http://msdn.microsoft.com/en-us/library/aa164019%28office.10%29.aspx#odc_tentipsvba_topic3

like image 65
Russel Yang Avatar answered Sep 26 '22 01:09

Russel Yang