This tutorial demonstrates the Excel REPLACE and SUBSTITUTE functions with practical examples. Learn how to use REPLACE with text, numbers, and dates, and how to nest multiple REPLACE or SUBSTITUTE functions within a single formula.
Last week, we explored the FIND and SEARCH functions. Today, we delve into two more functions for replacing text within a cell: REPLACE (based on position) and SUBSTITUTE (based on content).
Excel REPLACE Function
The REPLACE function swaps characters in a text string.
REPLACE(old_text, start_num, num_chars, new_text)
- old_text: The original text (or cell reference).
- start_num: The starting position of the replacement.
- num_chars: The number of characters to replace.
- new_text: The replacement text.
Example: Changing "sun" to "son": =REPLACE("sun", 2, 1, "o")
Or, using a cell reference: =REPLACE(A2, 2, 1, "o")
Using REPLACE with Numbers and Dates
REPLACE primarily works with text. While it can replace numeric characters within a text string, the result is always text (left-aligned, unlike numbers).
Example: =REPLACE(A2, 7, 4, "2016")
With dates, you must first convert the date to text using the TEXT function to avoid errors.
Example: =REPLACE(TEXT(A2, "dd-mmm-yy"), 4, 3, "Nov")
Nested REPLACE Functions
Multiple replacements can be achieved by nesting REPLACE functions.
Example: Adding hyphens to a phone number: =REPLACE(REPLACE(A2,4,0,"-"),8,0,"-")
Replacing Strings at Variable Positions
Use the FIND function to locate the starting position when the text to be replaced is at a different position in each cell.
Example: Replacing "ABC" with "BCA" in email addresses: =IFERROR(REPLACE(A2, FIND("@abc",A2), 4, "@bca"),A2)
(IFERROR handles cases where "@abc" isn't found).
Excel SUBSTITUTE Function
SUBSTITUTE replaces all or specific instances of a text string.
SUBSTITUTE(text, old_text, new_text, [instance_num])
- text: The original text.
- old_text: The text to replace.
- new_text: The replacement text.
-
instance_num (optional): The instance of
old_text
to replace (if omitted, all instances are replaced).
Example: Replacing the first "1" with "2": =SUBSTITUTE(A2, "1", "2", 1)
Nested SUBSTITUTE Functions
Multiple substitutions can be done by nesting SUBSTITUTE functions.
Example: =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,"PR","Project "),"ML","Milestone "),"T","Task ")
REPLACE vs. SUBSTITUTE
- SUBSTITUTE: Replaces based on content, all or specific instances.
- REPLACE: Replaces based on position and number of characters.
This concludes our guide. Download the practice workbook for further exploration.
The above is the detailed content of Using Excel REPLACE and SUBSTITUTE functions - formula examples. For more information, please follow other related articles on the PHP Chinese website!

This Excel charting tutorial provides a comprehensive guide to creating and customizing graphs within Microsoft Excel. Learn to visualize data effectively, from basic chart creation to advanced techniques. Everyone uses Excel charts to visualize dat

After you have created a chart in Excel, what's the first thing you usually want to do with it? Make the graph look exactly the way you've pictured it in your mind! In modern versions of Excel, customizing charts is easy and fun. Microsof

This tutorial demonstrates the Excel REPLACE and SUBSTITUTE functions with practical examples. Learn how to use REPLACE with text, numbers, and dates, and how to nest multiple REPLACE or SUBSTITUTE functions within a single formula. Last week, we ex

This tutorial details the syntax and advanced applications of Excel's FIND and SEARCH functions. Previous articles covered the basic Find and Replace dialog; this expands on using Excel to automatically locate and extract data based on specified cri

Google Sheets lacks built-in functions for summarizing data based on cell color. To overcome this, custom functions are provided that consider both font and background colors for basic calculations, enabling color-based summing and counting. These

This Excel pie chart tutorial guides you through creating and customizing pie charts. Learn to build effective pie charts, avoiding common pitfalls. Pie charts, also called circular graphs, visually represent proportions of a whole. Each slice repr

This tutorial shows how to create and modify Excel charts from data across multiple worksheets. Previously, we covered basic charting; this expands on that by addressing the common question of combining data from different sheets. Creating Charts fr

The dollar sign ($) in cell references in Excel formulas often confuses users, but its principle is simple. The dollar sign has only one function in Excel cell references: it tells Excel whether to change the reference when copying a formula to another cell. This tutorial will explain this feature in detail. The importance of Excel cell reference cannot be overemphasized. Understand the difference between absolute, relative, and mixed citations, and you've mastered half of the power of Excel formulas and functions. You may have seen the dollar sign ($) in the Excel formula and want to know what it is. In fact, you can refer to the same cell in four different ways, such as A1, $A


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Atom editor mac version download
The most popular open source editor
