nikki333
02-01-2018, 12:28 PM
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
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