Consulting

Results 1 to 3 of 3

Thread: Skip a fault 13 with an If code and go on with the macro

  1. #1
    VBAX Newbie
    Joined
    Nov 2017
    Posts
    1
    Location

    Skip a fault 13 with an If code and go on with the macro

    Dear all,


    I have a problem with my vba/macro. It suddenly has a problem with a value in a cell. Fault 13. Types doesn’t match. In some cells there is Indeed a diffrent type. But is it possible to skip the macro for that line and go to the Next?


    Thx for the help.

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    But is it possible to skip the macro for that line and go to the Next?
    Yes it is possible.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    Example:

    Sub SkipDemo()
        Dim oCell As Range
        On Error GoTo LocErr
        For Each oCell In Selection
            If oCell.Value = 10 Then
                'Warning, an error 13 still ends here!
                MsgBox "10!"
            End If
        Next
        Exit Sub
    LocErr:
        If Err.Number = 13 Then
            MsgBox "Error 13!"
            Resume Next
        Else
            MsgBox "Unexpected error!" & vbNewLine & Err.Number & vbNewLine & Err.Description, vbExclamation + vbOKOnly
            Stop
            'Resume gets you to the offending line of code:
            Resume
        End If
    End Sub
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

Tags for this Thread

Posting Permissions

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