Sometimes we want to find and replace words across worksheets or the whole workbook simultaneously, this operation will save a lot of time, otherwise it is time-consuming if we replace words by others in one worksheet then repeat the same operation in another worksheet. This free tutorial will show you the way to find and replace across multiple worksheets through Find and Replace feature and a VBA Code in Excel 2013/2016/2019/365, you can follow below steps to learn it.
Prepare two tables in two different worksheets but the same workbook. See screenshots below.
Table 1 in sheet1.
Table 2 in sheet2.
Now we want to replace ‘Available’ in two tables with ‘Good’.
Table of Contents
1. Find and Replace Across Worksheets by Holding on Multiple Worksheets
In precondition we prepare two tables in sheet1 and sheet2 separately, to illustrate the sample clearly, we also insert sheet3 and sheet4.
Step1: Sheet1 is opened. Press Ctrl key and hold on, then click on sheet2 to make two sheet2 are selected in the meanwhile. If you want to select sheet1 and sheet3, you can also press Ctrl key to select them, you can select not-adjacent sheets by holding Ctrl key.
If you want to select all worksheets, you can right click on sheet tab and select ‘Select All Sheets’.
Step2: Press Ctrl+H to trigger Find and Replace dialog. You can also trigger it by clicking on Home in ribbon, then click the small triangle on Find & Select icon, then select Replace.
Step3: In Find and Replace dialog, under Replace tab, in Find what textbox enter ‘Available’, in Replace with enter ‘Good’. Then click Replace All button.
All done message pops up.
Step4: Close Find and Replace dialog. Check the two tables.
At this time the two sheets are still selected.
a. If you want to do Find and Replace in the whole workbook, except ‘Select All Sheets’ in step#1, you can also apply below function.
After typing ‘Find what’ and ‘Replace with’, click on Options.
Select Workbook in Within dropdown list. Then replacement will apply on all worksheets properly.
2. Find and Replace Across Worksheets with VBA code
To find and replace across multiple worksheets in Excel using VBA code, you can follow these steps:
Step1: Open the Visual Basic Editor by pressing Alt + F11 in Excel.
Step2: In the VBA editor, insert a new module by clicking on “Insert” in the menu bar and selecting “Module“.
Step3: In the new module, paste the following VBA code:
Sub FindReplaceAllWorksheets_ExcelHow() Dim ws As Worksheet Dim findText As String Dim replaceText As String findText = InputBox("Enter the text you want to find:") replaceText = InputBox("Enter the text you want to replace it with:") For Each ws In Worksheets ws.Cells.Replace what:=findText, replacement:=replaceText, LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Next ws MsgBox "Find and Replace Complete!" End Sub
Step4: Run the macro by pressing F5 or by clicking the “Run” button in the VBA editor.
Step5: Excel will prompt you to enter the text you want to find and the text you want to replace it with. Enter the appropriate values and click “OK“.
The macro will then search for and replace the specified text across all worksheets in the workbook.
Step6: Once the macro has finished running, a message box will appear to let you know that the find and replace operation is complete.
3. Video: Find and Replace Across Worksheets by Holding on Multiple Worksheets
This video will demonstrate how to use the Find and Replace feature across multiple worksheets in Excel using VBA code.