Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Find and Replace - Replace with Blank Space | Excel Discussion (Misc queries) | |||
find and replace - replace data in rows to separated by commas | Excel Worksheet Functions | |||
Using Find and Replace to replace " in a macro | Excel Programming | |||
Replace method - cannot find any data to replace | Excel Programming | |||
Code to search and replace info on modules | Excel Programming |