I have to following code snippet ...
Public Sub FindText(path As String, file As String)
Dim Found As Range
myText = \"test(\"
MacroBook = Ac
You don't need to use 'Set' in your code. You only use this to assign a reference to an object. Try:-
For Each ws In Workbooks(file).Worksheets
With ws
Found = .UsedRange.Find(What:=myText, LookIn:=xlFormulas, _
LookAt:=xlPart, MatchCase:=False)
If Not Found Is Nothing Then
' do stuff
' ...
Hopefully this should work.
As follow up from comments to the Q, Error 2015
occurs because your formula in the sheet returns #VALUE!
error. You can handle it using IsError
:
If Not Found Is Nothing Then
If Not IsError(Found) Then
' do sth
End If
End If