TRATAMENTO DE ERRO

USUARIO.EXCLUIDOS 11/09/2006 15:42:07
#170684
pessoal quando rodo o programa...(um programinha em vba e excell) da um erro 1004 (run time erroR) mas quando trato o erro...ele nao é esse numero olhem a rotina...

Sub FailDesc()

'Function FailDesc(ind As Integer, OldLastRow As Integer) As String

'--------------
'DECLARE VARIABLES
'--------------

Dim intRMA, intKeyRow As Long
Dim intLRFind, intLRKeys As Long
Dim intCode, intActFind, intActKey As Long

Dim strINT, strRMA, strActRMA As String
Dim strKey1, strKey2, strKey3, strKey4, strKey5 As String
Dim strKeyAct(5) As String
Dim oFindings, oNew, oRMA_C As Worksheet

'--------------
'USER INPUT VARIABLES
'--------------

Set oFindings = Worksheets("FINDINGS")
Set oRMA_C = Worksheets("RMA_C")
Set oNew = Worksheets("NEW")
Set oKey = Worksheets("KEYWORDS")

'find last row in the sheet FINDINGS
intLRFind = oFindings.Cells.Find(What:="*", After:=[A1], _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

'find last row in the sheet KEYWORDS
intLRKeys = oKey.Cells.Find(What:="*", After:=[A1], _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

'--------------
'Concatenate all the cells in a single cell
'to execute the find command
'--------------

' Points Concatenated RMA to 2nd cell
intRMA = 2

For intActFind = 2 To intLRFind
If oFindings.Range("A" & intActFind) = "" Or IsNull(oFindings.Range("A" & intActFind)) Then
'strRMA = ""
strRMA = strRMA & vbLf & oFindings.Range("J" & intActFind)
oRMA_C.Range("B" & intRMA) = strRMA
Else
intRMA = intRMA + 1
oRMA_C.Range("A" & intRMA) = oFindings.Range("A" & intActFind)
strRMA = oFindings.Range("J" & intActFind)
oRMA_C.Range("B" & intRMA) = strRMA
End If
Next intActFind

'-----------------------------------
'Search the RMA strings for specific
'Keywords and give FAIL_DESC_OP
'-----------------------------------

On Error GoTo error_noMatch

For intActFind = 2 To intLRFind

return_Loop:
intActRMA = oNew.Range("X" & intActFind)

If IsNumeric(intActRMA) Then
strActRMA = Trim(CStr(intActRMA))
Else
strActRMA = intActRMA
End If
If WorksheetFunction.IsError(WorksheetFunction.Match(strActRMA, oRMA_C.Range("A2:A" & intLRFind), 0)) Then
intRMA = intLRKeys
Else
intRMA = WorksheetFunction.Match(strActRMA, oRMA_C.Range("A2:A" & intLRFind), 0)

End If


'-----------------------------------
' Begin of tests
'
' LEGEND
' intActFind : Current Analyzed FINDING
' z : SHOP FINDING CODES
' intActKey : KEYWORDS
'-----------------------------------

For intActKey = 2 To intLRKeys

'test if key1 is filled out
If IsNull(oKey.Cells(intActKey, 1)) Or oKey.Cells(intActKey, 1) = "" Then
MsgBox "Missing Keyword at row " & intActKey & " on sheet KEYWORDS", vbCritical, "Keyword Error"
Exit Sub
End If

'copy the keys to their respective strings
For intKeyColumn = 1 To 5
strKeyAct(intKeyColumn) = oKey.Cells(intActKey, intKeyColumn) 'Column A / Key1
Next intKeyColumn

'fills out the blank keywords with key1
For intKeyColumn = 2 To 5
If IsNull(strKeyAct(intKeyColumn)) Or strKeyAct(intKeyColumn) = "" Then strKeyAct(intKeyColumn) = oKey.Cells(intActKey, 1)
Next intKeyColumn


'test keywords against strRMA
If (oRMA_C.Cells(intRMA, 2) Like strKeyAct(1)) And (oRMA_C.Cells(intRMA, 2) Like strKeyAct(2)) _
And (oRMA_C.Cells(intRMA, 2) Like strKeyAct(3)) And (oRMA_C.Cells(intRMA, 2) Like strKeyAct(4)) _
And (oRMA_C.Cells(intRMA, 2) Like strKeyAct(5)) Then

'write on column Q Fail_Desc_OP the answer based on the criteria from oKEY
oNew.Range("Q" & intActFind).Value = oKey.Cells(intActKey, 6)

'write on column Q Fail_Desc_OP the answer based on the criteria from oKEY
oNew.Range("R" & intActFind).Value = oKey.Cells(intActKey, 7)

End If

Next intActKey
error_noMatch:
If Err = 1004 Then
intActFind = intActFind + 1
GoTo return_Loop
End If

Next intActFind

End Sub

USUARIO.EXCLUIDOS 11/09/2006 16:08:51
#170695
ta na mesma...ocorre o erro...mas mesmo com o tratamento ele nao vai para o goto do tratamento ocorre o erro e no debug para na linha dele....nem vai para o
error_noMatch:

para na linha:
If WorksheetFunction.IsError(WorksheetFunction.Match(strActRMA, oRMA_C.Range("A2:A" & intLRFind), 0)) Then
LIONHEART 11/09/2006 16:15:44
#170698
coloca o on error ... na primeira linha do seu codigo.
USUARIO.EXCLUIDOS 11/09/2006 16:19:31
#170700
ta na mesma....
tentei colocar em anexo a planilha...mas esta com erro...
Tópico encerrado , respostas não são mais permitidas