#1
|
|||
|
|||
Find and replace only the last match
The code below will find and replace all keywords in a selection.
Code:
With Selection.Find .ClearFormatting .Text = "keyword" .Replacement.Text = "replacement_keyword" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll Alex |
#2
|
||||
|
||||
That's as simple as changing:
.Forward = True to .Forward = False and: wdReplaceAll to: wdReplaceOne
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Thank you, Paul! Just what I needed...
Indeed, very simple, but only for those that know their craft! For the rest of us (starting with me), things can be tricky and time consuming... ;-) Alex |
#4
|
||||
|
||||
A bit of time spent in the VBA help files could have led you to that solution.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
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 a match and move row to top of page | Auto | Excel Programming | 3 | 03-08-2016 01:17 AM |
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 |