Skip to content
Free Excel Tutorials
  • Home
  • Excel For Beginners
  • Excel Intermediate
  • Advanced Excel For Experts

Data Analysis

  • Understanding Pivot Tables in Excel
  • Chart Axes in Excel
  • How to create Checklist in Excel
  • How To Create Pareto Chart in Excel
  • Remove Duplicates Example in Excel

References

  • LOOKUP function: Description, Usage, Syntax, Examples and Explanation
  • Count rows with at least n matching values
  • Approximate match with multiple criteria in Excel
  • CHOOSE function: Description, Usage, Syntax, Examples and Explanation
  • Basic INDEX MATCH approximate in Excel

Data Validations

  • Excel Data validation require unique number
  • Excel Data validation only dates between
  • How To Create Drop-down List in Excel
  • Excel Data validation don’t exceed total
  • Excel Data validation no punctuation

How to find and replace multiple values at same time in Excel

by

To find and replace multiple values with a formula, you can nest multiple SUBSTITUTE functions together, and feed in find/replace pairs from another table using the INDEX function.

Formula

=SUBSTITUTE(SUBSTITUTE(B5,INDEX(find,1),INDEX(replace,1)),
INDEX(find,2),INDEX(replace,2))

How to find and replace multiple values at same time in Excel

Explanation

In the example shown, we are performing 4 separate find and replace operations. The formula in G5 is:

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B5,INDEX(find,1),
INDEX(replace,1)),INDEX(find,2),INDEX(replace,2)),
INDEX(find,3),INDEX(replace,3)),INDEX(find,4),INDEX(replace,4))

where “find” is the named range E5:E8, and “replace” is the named range F5:F8. See below for info on how to make this formula easier to read.

Preface

There is no built-in formula for running a series of find and replace operations in Excel, so this a “concept” formula to show one approach. The text to look for and replace with is stored directly on the worksheet in a table, and retrieved with the INDEX function. This makes the solution “dynamic” – any of these values are changed, results update immediately. Of course, there is no requirement to use INDEX; you can hard-code values into the formula if you prefer.

Worked Example:   Extract word that begins with specific character in Excel

How this formula works

At the core, the formula uses the SUBSTITUTE function to perform the each substitution, with this basic pattern:

=SUBSTITUTE(text,find,replace)

“Text” is the incoming value, “find” is the text to look for, and “replace” is the text to replace with. The text to look for and replace with is stored in the table to the right, in the range E5:F8, one pair per row. The values on the left are in the named range”find”and the values on the right are in the named range “replace”.  The INDEX function is used to retrieve both the “find” text and the “replace” text like this:

INDEX(find,1) // first "find" value
INDEX(replace,1) // first "replace" value

So, to run the first substitution (look for “red”, replace with “pink”) we use:

=SUBSTITUTE(B5,INDEX(find,1),INDEX(replace,1))

In total, we run four separate substitutions, and each subsequent SUBSTITUTE begins with the result from the previous SUBSTITUTE:

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B5,INDEX(find,1),
INDEX(replace,1)),INDEX(find,2),INDEX(replace,2)),
INDEX(find,3),INDEX(replace,3)),INDEX(find,4),INDEX(replace,4))

Line breaks for readability

You’ll notice this kind of nested formula is quite difficult to read. By adding line breaks, we can make the formula much easier to read and maintain:

=
SUBSTITUTE(
SUBSTITUTE(
SUBSTITUTE(
SUBSTITUTE(
B5,
INDEX(find,1),INDEX(replace,1)),
INDEX(find,2),INDEX(replace,2)),
INDEX(find,3),INDEX(replace,3)),
INDEX(find,4),INDEX(replace,4))

The formula bar in Excel ignores extra white space and line breaks, so the above formula can be pasted in directly:

Worked Example:   Extract multiple matches into separate rows in Excel

How to find and replace multiple values at same time in Excel

By the way, there is a keyboard shortcut for expanding and collapsing the formula bar.

Worked Example:   Extract data with helper column in Excel

More substitutions

More rows can be added to the table to handle more find/replace pairs. Each time a pair is added, the formula needs to be updated to include the new pair. It’s important also to make sure the named ranges (if you are using them) are updated to include new values as needed. Alternately, you could use a proper Excel Table for dynamic ranges, instead of named ranges.

Other uses

The same approach can be used clean up text by “stripping” punctuation and other symbols from text with a series of substitutions.

Post navigation

Previous Post:

Put names into proper case — Manipulating NAMES in Excel

Next Post:

Create One-dimensional and Two-dimensional Array

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Learn Basic Excel

Ribbon
Workbook
Worksheets
Format Cells
Find & Select
Sort & Filter
Templates
Print
Share
Protect
Keyboard Shortcuts

Categories

  • Charts
  • Data Analysis
  • Data Validation
  • Excel Functions
    • Cube Functions
    • Database Functions
    • Date and Time Functions
    • Engineering Functions
    • Financial Functions
    • Information Functions
    • Logical Functions
    • Lookup and Reference Functions
    • Math and Trig Functions
    • Statistical Functions
    • Text Functions
    • Web Functions
  • Excel VBA
  • Excel Video Tutorials
  • Formatting
  • Grouping
  • Others

Logical Functions

  • How to return blank in place of #DIV/0! error in Excel
  • IF function: Description, Usage, Syntax, Examples and Explanation
  • FALSE function: Description, Usage, Syntax, Examples and Explanation
  • How to use Excel NOT Function
  • IF with wildcards in Excel

Date Time

  • How to calculate Next working/business day in Excel
  • DATEVALUE function: Description, Usage, Syntax, Examples and Explanation
  • ISOWEEKNUM function: Description, Usage, Syntax, Examples and Explanation
  • Get work hours between dates in Excel
  • How to get number of days, weeks, months or years between two dates in Excel

Grouping

  • Calculate conditional mode with criteria in Excel
  • Map inputs to arbitrary values in Excel
  • How to randomly assign people to groups in Excel
  • Group times into unequal buckets in Excel
  • Running count group by n size in Excel

General

  • Mark Workbook as Final in Excel
  • How to calculate percentage discount in Excel
  • Count cells less than in Excel
  • How to get amount with percentage in Excel
  • Check if multiple cells have same value in Excel
© 2023 xlsoffice . All Right Reserved. | Teal Smiles | Abbreviations And Their Meaning