OzzieTheOwl
Technical User
Hi
The code below is looking for a matach from one sheet to another, works fine when there is a match, but when there is no match it gives me a Run Time Error 91. I understand this is because there is no match, but I thought the "On Error" line would sort that out. Have I done something obviously wrong?
Any help greatly appreciated.
The code below is looking for a matach from one sheet to another, works fine when there is a match, but when there is no match it gives me a Run Time Error 91. I understand this is because there is no match, but I thought the "On Error" line would sort that out. Have I done something obviously wrong?
Any help greatly appreciated.
Code:
For APlantLoop = 2 To APlantLastRow
APlantFleetNum = Sheets("A-Plant").Range("G" & APlantLoop)
APlantDesc = Sheets("A-Plant").Range("J" & APlantLoop)
If Sheets("A-Plant").Range("L" & APlantLoop) = "SALES" Then GoTo APlantEnd
Sheets("BBUL").Select
Range("A1").Select
On Error GoTo NoAPlantMatch
Cells.Find(What:=APlantFleetNum, After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Activate
BBULRow = ActiveCell.Row
BBULFleetNum = Sheets("BBUL").Range("D" & BBULRow)
BBULDesc = Sheets("BBUL").Range("C" & BBULRow)
If BBULFleetNum = APlantFleetNum Then APlantCheck = 1
NoAPlantMatch:
'Code Here
APlantEnd:
APlantCheck = 0
Next APlantLoop