search
HomeSoftware TutorialOffice SoftwareUsing Excel REPLACE and SUBSTITUTE functions - formula examples

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 Excel REPLACE and SUBSTITUTE functions - formula examples

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")

Using Excel REPLACE and SUBSTITUTE functions - formula examples

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")

Using Excel REPLACE and SUBSTITUTE functions - formula examples

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,"-")

Using Excel REPLACE and SUBSTITUTE functions - formula examples

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

Using Excel REPLACE and SUBSTITUTE functions - formula examples

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)

Using Excel REPLACE and SUBSTITUTE functions - formula examples

Nested SUBSTITUTE Functions

Multiple substitutions can be done by nesting SUBSTITUTE functions.

Example: =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,"PR","Project "),"ML","Milestone "),"T","Task ")

Using Excel REPLACE and SUBSTITUTE functions - formula examples

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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How to make a chart (graph) in Excel and save it as templateHow to make a chart (graph) in Excel and save it as templateApr 28, 2025 am 09:31 AM

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

Excel charts: add title, customize chart axis, legend and data labelsExcel charts: add title, customize chart axis, legend and data labelsApr 28, 2025 am 09:18 AM

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

Using Excel REPLACE and SUBSTITUTE functions - formula examplesUsing Excel REPLACE and SUBSTITUTE functions - formula examplesApr 28, 2025 am 09:16 AM

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

Excel FIND and SEARCH functions with formula examplesExcel FIND and SEARCH functions with formula examplesApr 28, 2025 am 09:09 AM

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

Count & sum cells by color in Google SheetsCount & sum cells by color in Google SheetsApr 28, 2025 am 09:04 AM

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

How to make a pie chart in ExcelHow to make a pie chart in ExcelApr 27, 2025 am 09:37 AM

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

How to create a chart in Excel from multiple sheetsHow to create a chart in Excel from multiple sheetsApr 27, 2025 am 09:22 AM

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

Why use $ in Excel formula: relative & absolute cell referenceWhy use $ in Excel formula: relative & absolute cell referenceApr 27, 2025 am 09:13 AM

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

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

DVWA

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

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

Atom editor mac version download

The most popular open source editor