Search code examples
vbaexcelcustom-error-handling

VBA - Error handling with writing the arguments


Hello nice friendly people. I would be as specific as possible. The question is the following:

Why the first line works in the VBE immediate window, while the second one does not? How can I make the second line work?

err.Raise 999,,"EA"
err.Raise err.Number:= 999,err.Description:= "EA"

Solution

  • Don't refer to err.X in your call, just set X:=...:

    err.Raise Number:=999, Description:= "EA"