problem with Find next matching cell resolved
The code below is to find matches to the string, word.
If there is more then 1 match in a column the code works fine. If there is only 1 match then it finds this one match twice. Instead of finding the 1 match twice, how do I exit sub if there is no second match?
smiler44
On Error GoTo errorhandler ' if no match found go to errorhandler
Cells.find(what:=word).Activate
If ActiveCell.Text = word Then
MsgBox ("matchfound")
pause (1)
Cells.FindNext(After:=ActiveCell).Activate
errorhandler: Exit Sub ' no match found
End If
The code below is to find matches to the string, word.
If there is more then 1 match in a column the code works fine. If there is only 1 match then it finds this one match twice. Instead of finding the 1 match twice, how do I exit sub if there is no second match?
smiler44
On Error GoTo errorhandler ' if no match found go to errorhandler
Cells.find(what:=word).Activate
If ActiveCell.Text = word Then
MsgBox ("matchfound")
pause (1)
Cells.FindNext(After:=ActiveCell).Activate
errorhandler: Exit Sub ' no match found
End If
Last edited: