hello,
could anyone help me with the following problem:
I've got a macro which searches all worksheets of a workbook for a certain value (entered by user).
It works ok, but the problem is that it generates the error message for each worksheet and I just want one at the end of the search.
here's the code:
could anyone help me with the following problem:
I've got a macro which searches all worksheets of a workbook for a certain value (entered by user).
It works ok, but the problem is that it generates the error message for each worksheet and I just want one at the end of the search.
here's the code:
Code:
Sub zoek()
Dim FindString As String
Dim Rng As Range
FindString = InputBox("vul het dossiernummer in")
If Trim(FindString) <> "" Then
For Each sh In ActiveWorkbook.Worksheets
With sh.Cells
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
Application.Goto Rng, True
Else
MsgBox "klacht niet gevonden"
End If
End With
Next sh
End If
End Sub