Method 1 – Multiple Sheets
In the following image, you can see that we have an Excel sheet named One.
In the same workbook, we have another sheet named Two.
We will replace the word “Ambrose” with “Moxley”.
- Open your Excel workbook.
- From the Home tab, select Find & Select and click on Replace.
- A Find and Replace pop-up box will appear. Click on the Options (shown in the image below).
- New options will show in the pop-up box.
- Enter the word you want to find (e.g., “Ambrose”) in the Find what section.
- Enter the replacement word (e.g., “Moxley”) in the Replace with section.
- Choose Workbook from the drop-down list next to Within to search all sheets in the workbook.
- Click Replace All.
- Confirm the replacements. If you have more sheets, additional replacements will occur.
Check whether the replacements occurred or not.
Consider both the above and the following images.
The word “Ambrose” from both of our sheets is now replaced with the word “Moxley”.
Read More: How to Find and Replace within Selection in Excel
Method 2 – Multiple Sheets of Multiple Workbooks
Look at the following images. We have opened two Excel workbooks. One is named Find and Replace Value (see the image below).
Another one is named Transpose Multiple Columns (shown in the picture below).
Once you have done replacing value from one specific worksheet discussed in the above section, you will notice that the Find and Replace pop-up box is open.
- Keep the Find and Replace pop-up box open.
- Hover over the next workbook without closing the pop-up box.
- Press Replace All to find and replace values in all worksheets of that workbook.
Repeat for as many workbooks as needed.
Read More: How to Find and Replace Multiple Words from a List in Excel
Method 3 – Embedding VBA
- Press Alt + F11 on your keyboard or go to the Developer tab, click on Visual Basic to open the Visual Basic Editor.
- In the pop-up code window, click Insert and select Module from the menu bar.
- Copy the following code and paste it into the code window.
Sub MultipleFindAndReplace()
Dim iSheet As Worksheet
Dim OldValue As Variant
Dim NewValue As Variant
Dim i As Long
OldValue = Array("John", "Roman", "Dean", "Seth", "Finn")
NewValue = Array("Ben", "Alex", "Joe", "Chris", "Josh")
For i = LBound(OldValue) To UBound(OldValue)
For Each iSheet In ActiveWorkbook.Worksheets
iSheet.Cells.Replace What:=OldValue(i), Replacement:=NewValue(i), LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Next iSheet
Next i
End Sub
This code will replace the array of values “John, Roman, Dean, Seth, Finn” with the values “Ben, Alex, Joe, Chris, Josh”.
- Press F5 on your keyboard or select Run and click on Run Sub/UserForm from the menu bar.
- Alternatively, click the small Run icon in the sub-menu bar to execute the macro.
- Check the workbook to see that all values (“John,” “Roman,” “Dean,” “Seth,” “Finn”) have been replaced with their corresponding values (“Ben,” “Alex,” “Joe,” “Chris,” “Josh”).
- Execute this code on one workbook.
- Hover over to another workbook.
- Go to Developer, choose Macros and select the macro name.
- Click Run to apply the same replacements to the other workbook.
The VBA code scans each worksheet in the active workbook, replacing the specified values. It’s a powerful way to automate find-and-replace tasks.
VBA Code Explanation
Dim iSheet As Worksheet
Dim OldValue As Variant
Dim NewValue As Variant
Dim i As Long
Defining the variables.
OldValue = Array("John", "Roman", "Dean", "Seth", "Finn")
NewValue = Array("Ben", "Alex", "Joe", "Chris", "Josh")
Set the values to find in the OldValue variable and set the values to replace in the NewValue variable.
For i = LBound(OldValue) To UBound(OldValue)
For Each iSheet In ActiveWorkbook.Worksheets
iSheet.Cells.Replace What:=OldValue(i), Replacement:=NewValue(i), LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Next iSheet
Next i
This code will first loop through each item in the Array lists. Then loop through each worksheet in ActiveWorkbook. After scanning, it will replace the OldValue with the NewValue when it finds the match. After the iteration in one sheet, it will then move into the next sheet and start executing the loop again.
Download Workbook
You can download the practice workbook from here:
Related Articles
- How to Find and Replace Text Color in Excel
- How to Show Dash Instead of Zero in Excel
- Replace Text of a Cell Based on Condition in Excel
- How to Find and Replace Using Formula in Excel
- How to Replace Text in Excel Formula
<< Go Back to Find and Replace | Learn Excel
Get FREE Advanced Excel Exercises with Solutions!