![]() |
|
#1
|
|||
|
|||
|
Greeting to all,
I have been using find and replace through vba. It works fine except, sometimes it replaces whole document instead of just replacing the selection. The code I am using is below: Sub Macro32() ' ' Macro32 Macro ' ' With selection .Find.ClearFormatting .Find.Replacement.ClearFormatting End with With Selection.Find .Text = "^t" .Replacement.Text = "" .Forward = True .Wrap = wdFindStop .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll With selection .Find.ClearFormatting .Find.Replacement.ClearFormatting End with With Selection.Find .Text = "(=)" .Replacement.Text = "^t\1" .Forward = True .Wrap = wdFindStop .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll End Sub How could I modify this code to just replace the selected area and nothing else? Looking forward for suggestions. Thanks in advance. |
| Tags |
| find |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How do you use the find and replace tool to find dates and times in Excel 2013? | Jules90 | Excel | 3 | 04-14-2020 07:40 PM |
| In Find and Replace, can Word stop after each Replace? | wardw | Word | 1 | 06-08-2017 02:47 PM |
Find what box in Find and replace limits the length of a search term
|
Hoxton118 | Word VBA | 7 | 06-10-2014 05:05 AM |
Bad view when using Find and Find & Replace - Word places found string on top line
|
paulkaye | Word | 4 | 12-06-2011 11:05 PM |
| Automatic find replace after selection in dropdown | vsempoux | Word | 0 | 10-28-2009 08:45 AM |