How to find and replace multiple words at the same time in a Word document?
Word provides a Find and Replace function to find all instances of a word or phrase and replace them with a new word at the same time. But if you want to find and replace different words at the same time, this build-in function can’t help. In this article, we are talking about a VBA method to find and replace multiple different words at the same time in Word document.
Please do as follows to find and replace multiple word at the same time in a Word document.
1. Open the Word document you want to find and replace multiple words at the same time, then press the Alt + F11 keys to open the Microsoft Visual Basic for Applications window.
2. In the Microsoft Visual Basic for Applications window, click Insert > Module. Then copy below VBA code into the Module window.
VBA code: Find and replace multiple words at the same time in Word
Sub FindAndReplaceMultiItems() 'Update by ExtendOffice 2018/10/25 Dim xFind As String Dim xReplace As String Dim xFindArr, xReplaceArr Dim I As Long Application.ScreenUpdating = False xFind = InputBox("Enter items to be found here,seperated by comma: ", "Kutools for Word") xReplace = InputBox("Enter new items here, seperated by comma: ", "Kutools for Word") xFindArr = Split(xFind, ",") xReplaceArr = Split(xReplace, ",") If UBound(xFindArr) <> UBound(xReplaceArr) Then MsgBox "Find and replace characters must be equal.", vbInformation, "Kutools for Word" Exit Sub End If For I = 0 To UBound(xFindArr) Selection.HomeKey Unit:=wdStory With Selection.Find .ClearFormatting .Replacement.ClearFormatting .Text = xFindArr(I) .Replacement.Text = xReplaceArr(I) .Format = False .MatchWholeWord = False End With Selection.Find.Execute Replace:=wdReplaceAll Next Application.ScreenUpdating = True End Sub
3. Press the F5 key to run the code.
4. In the first Kutools for Word dialog box, enter the multiple words you will find and replace into the textbox, and separate them with comma, then click the OK button. See screenshot:
5. In the second Kutools for Word dialog box, enter the new words you will replace with (these words also need to be separated by commas), and then click the OK button.
Note: In this case, all “KTE” in this document will be replaced with “New”, and “KTO” and “KTW” will be replaced with “Test” and “Finish”. Please change them to your needs.
Recommended Word Productivity Tools
- Complicated and repeated operations can be done one-time processing in seconds.
- Insert multiple images across folders into Word document at once.
- Merge and combine multiple Word files across folders into one with your desired order.
- Split the current document into separate documents according to heading, section break or other criteria.
- Convert files between Doc and Docx, Docx and PDF, collection of tools for common conversions and selection, and so on...
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
To post as a guest, your comment is unpublished.· 1 months agoHi, This works well with English Words. Now I am doing a document where I translate English to Gujarati. So, when I apply this, (Find English Words) and (Replace with Gujarati words), it does change but it appears like "???". Doesn't show the Gujarati word but just question marks? Any further help? Please.
To post as a guest, your comment is unpublished.· 2 months agoAny way to make this case sensitive?
To post as a guest, your comment is unpublished.· 3 months agowill this work in office Excel 365
To post as a guest, your comment is unpublished.· 6 months agoToto jsem hledal, jen potřebuji pro hledaný text přidat nějaké formátování. Jak toho dosáhnu?