JenniferMurphy
Well-known Member
- Joined
- Jul 23, 2011
- Messages
- 2,687
- Office Version
- 365
- Platform
- Windows
This web page,
http://www.cpearson.com/excel/ErrorHandling.htm
has this to say about On Error GoTo 0
In my code, it isn't working. This line causes a Value error in the calling cell.
VBA does not "display its standard run time message box" as claimed above. I discovered by trapping the error that it is actually an Error 448 (missing parameter) caused by passed a null (,,) argument. Am I doing something wrong or is the text wrong?
Second question. Since the above is not working, I decided to write my own error handler. Here's my code:
Is there a better way to handle this situation?
http://www.cpearson.com/excel/ErrorHandling.htm
has this to say about On Error GoTo 0
The first form, On Error Goto 0, is the default mode in VBA. This indicates that when a run time error occurs VBA should display its standard run time error message box, allowing you to enter the code in debug mode or to terminate the VBA program. When On Error Goto 0 is in effect, it is the same as having no enabled error handler. Any error will cause VBA to display its standard error message box.
In my code, it isn't working. This line causes a Value error in the calling cell.
Code:
Parms = Split(PArgs(i), "=")
Second question. Since the above is not working, I decided to write my own error handler. Here's my code:
Code:
Public Function WtdRtg(p1, p2, ParamArray PArgs())
. . .
On Error GoTo PAErrorHandler:
Dim i As Integer 'Loop index
Dim Parms() As String 'Array for splitting parameters
For i = 0 To UBound(PArgs, 1) 'Loop thru the parameter array
Parms = Split(PArgs(i), "=") 'Split off the next parameter
. . .
Next i
GoTo PAErrorHandlerDone
PAErrorHandler: Stop
MsgBox "Invalid paramarray parameter (#" & i + 1 & ")"
WtdRtg = CVErr(xlErrValue)
Exit Function
PAErrorHandlerDone:
. . .
End Function
Is there a better way to handle this situation?