Consulting

Results 1 to 14 of 14

Thread: Error Handling (runtime error 1004)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Contributor
    Joined
    Jul 2017
    Location
    Zurich
    Posts
    132
    Location

    Error Handling (runtime error 1004)

    Hey Folks

    Having trouble getting my error handling to work.

    In this procedure I'm using the match function to write data from an array to a worksheet.

    In a few cases there is no match (so it errors with: the match function cannot be assigned), and i'd like the error handler to skip it and go on finding the next match,
    but it ignores the "on Error goto NoMatch:"


        With wsMatrix
            For q = 6 To lrMatrix
                For r = 1 To numHelper
                    If .Range("B" & q) = arrTeilnehmerResults(r, 1) Then
                        On Error GoTo NoMatch:
                        s = WorksheetFunction.Match(arrTeilnehmerResults(r, 2), rngTrainingNrMatrix, 0)
                        With .Cells(q, s)
                            .Value = arrTeilnehmerResults(r, 4)
                            If arrTeilnehmerResults(r, 4) < .Offset(0, 2) Then
                                .Interior.Color = RGB(255, 174, 172)
                            Else:
                                .Interior.Color = RGB(226, 239, 218)
                            End If
                        End With
                        .Cells(q, s + 1) = arrTeilnehmerResults(r, 3)
                    End If
    Weiter:
                Next r
            Next q
        End With
    
    
    NoMatch:
        GoTo Weiter:
    
    End with
    Last edited by Paul_Hossler; 02-01-2018 at 02:33 PM. Reason: Added CODE tags

Posting Permissions

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