Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Use of on error

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    John G
    Posts
    62
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    What types of events or code would you put an on error in? I have an application that opens and closes another workbook, saves, and switches betweeen different sheets quite a bit. Is there somewhere I can go to find out more about "on error" and how to correctly use it?

    John

  2. #2
    Board Regular
    Join Date
    Feb 2002
    Posts
    3,184
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi

    try the VBE help file ERRORS

    Error Statement Example
    This example uses the Error statement to simulate error number 11.

    On Error Resume Next ' Defer error handling.
    Error 11 ' Simulate the "Division by zero" error.

    """"""""

    Error Object, Errors Collection, and Description, Number, Source, HelpFile, and HelpContext Properties Example

    This example forces an error, traps it, and displays the Description, Number, Source, HelpContext, and HelpFile properties of the resulting Error object.

    Sub DescriptionX()

    Dim dbsTest As Database

    On Error GoTo ErrorHandler

    ' Intentionally trigger an error.
    Set dbsTest = OpenDatabase("NoDatabase")

    Exit Sub

    ErrorHandler:
    Dim strError As String
    Dim errLoop As Error

    ' Enumerate Errors collection and display properties of
    ' each Error object.
    For Each errLoop In Errors
    With errLoop
    strError = _
    "Error #" & .Number & vbCr
    strError = strError & _
    " " & .Description & vbCr
    strError = strError & _
    " (Source: " & .Source & ")" & vbCr
    strError = strError & _
    "Press F1 to see topic " & .HelpContext & vbCr
    strError = strError & _
    " in the file " & .HelpFile & "."
    End With
    MsgBox strError
    Next

    Resume Next

    End Sub

    ::::::::::

    that sort of thing what you looking for?

    Free Excel based Web Toolbar available here.

    Jack in the UK
    J & R Excel Solutions
    "making Excel work for you"

  3. #3
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Bogota, Colombia
    Posts
    11,959
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Nice explanation Jack !
    Regards,

    Juan Pablo González
    http://www.juanpg.com

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •