Need some help understanding how I can get my OnError to work every time. I am looping through a labor report that is poorly formatted so I'm using the find functionality in Excel. If a name doesn't exist I'm (Error 91) I'm telling it to put 0s in the hours then goto the next name in the list. It works on the first name but not on the second. Here is some of the code. First time posting so please be gentle. Thank you!
On Error GoTo NoName
If a = 1 Then
Cells.Select
Selection.Find(What:=stremployee, After:=ActiveCell, LookIn _
:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
lngrow = ActiveCell.Row
Else
Range("A" & lngEndRow - 5).Select
Cells.Find(What:=stremployee, After:=ActiveCell, LookIn:=xlValues _
, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
lngrow = ActiveCell.Row
End If
More code...
NoName:
Sheets("Summary").Activate
Cells(lngActRow, 4) = dbltotreg
Cells(lngActRow, 5) = dblot
Cells(lngActRow, 6) = dbldt
Range("A1").Select
dbltotreg = 0
dblot = 0
dbldt = 0
a = a + 1
Next cell
Bookmarks