Hi,
I pick up a name from sheet one, switch to sheet two and search for the name.
I then copy data from alongside the name and paste it back into sheet one.
No problem until it doesn't find the name on sheet two where it crashed.
So I added error checking but now it works OK until the first missing name on sheet two and then errors on every name after that.
What have I missed please:
************************
On Error GoTo ErrSub
for n=1 to rowcount
Skip = "no"
xfer1 = "A" & Trim(Str)
Range(xfer1).Select
xfer2 = ActiveCell.Value
Sheets(TWO).Select
Columns("A:A").Select
Range("A2").Select
Selection.Find(What:=xfer2, After:=ActiveCell, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Activate
' Ok until first selection not found then rejects every selection afterwards
' gives error 91, something about 'with / end with'
If Skip = "no" Then
'rest of program
Sheets(ONE).Select
end if
next n
exit sub
ErrSub:
myResponse = MsgBox("Error in " & xfer2, vbOKOnly)
Sheets(ONE).Select
Skip = "yes"
Resume Next
end sub
***********************
Regards
Peter
I pick up a name from sheet one, switch to sheet two and search for the name.
I then copy data from alongside the name and paste it back into sheet one.
No problem until it doesn't find the name on sheet two where it crashed.
So I added error checking but now it works OK until the first missing name on sheet two and then errors on every name after that.
What have I missed please:
************************
On Error GoTo ErrSub
for n=1 to rowcount
Skip = "no"
xfer1 = "A" & Trim(Str)
Range(xfer1).Select
xfer2 = ActiveCell.Value
Sheets(TWO).Select
Columns("A:A").Select
Range("A2").Select
Selection.Find(What:=xfer2, After:=ActiveCell, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Activate
' Ok until first selection not found then rejects every selection afterwards
' gives error 91, something about 'with / end with'
If Skip = "no" Then
'rest of program
Sheets(ONE).Select
end if
next n
exit sub
ErrSub:
myResponse = MsgBox("Error in " & xfer2, vbOKOnly)
Sheets(ONE).Select
Skip = "yes"
Resume Next
end sub
***********************
Regards
Peter