Getting info from FIND/REPLACE
Hi Gary
Not using Replace, but does the following help?
Sub Macro2()
Dim ws As Worksheet
For Each ws In Worksheets
ws.Activate
Set rng = Cells.Find(what:="xxx")
If Not rng Is Nothing Then
Cells.Replace what:="xxx", Replacement:="yyy"
MsgBox "found&replaced"
Exit Sub
End If
Next
End Sub
Richard
PS: Season's Greetings to you & your family!
Gary''s Student wrote:
I run something like:
Sub Macro2()
Dim ws As Worksheet
For Each ws In Worksheets
ws.Activate
Cells.Replace What:="xxx", Replacement:="yyy"
Next
End Sub
This runs over many, many sheets. Most sheets don't have the string. Is
there any way I can return something from Replace to tell me if any
replacements were actually made in a given sheet?
I would like to break out of the loop once I get to the sheet that contained
the string in question.
--
Gary's Student
|