How to Find and Replace Values in Multiple Excel Files (3 Methods)

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.

Starting Find and replace option to find and replace in multiple excel files

  • A Find and Replace pop-up box will appear. Click on the Options (shown in the image below).

Options to find and replace in multiple excel files

  • 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.

Find and replace value in multiple excel files

  • Confirm the replacements. If you have more sheets, additional replacements will occur.

Confirmation msg to find and replace in multiple excel files

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

VBA to find and replace in multiple excel files

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”).

Result of VBA to find and replace in multiple excel files

  • 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


<< Go Back to Find and Replace | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Sanjida Ahmed
Sanjida Ahmed

Sanjida Ahmed, who graduated from Daffodil International University with a degree in Software Engineering, has worked with SOFTEKO since 2021. She has written over 100 articles on Excel & VBA and, since 2022, has worked as the Project Manager of the Excel Extension Development Project in the Software Development Department. Since starting this software development, she has established an outstanding workflow encompassing a full SDLC. She always tries to create a bridge between her skills and interests in... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo