Function Problems

How to Replace Partial Text in an Excel Cell Based on Its Value

Steven ParkerSteven Parker Nov 11, 2026 869 views

Question details

The user needs to dynamically replace or shift a specific character within a structured text string in an Excel cell, such as changing 'Company-a2' to 'Company-c2'.

How to Replace Partial Text in an Excel Cell Based on Its Value
Product
Excel
Device & OS
not provided
Scenario
Modifying structured text data where a specific character needs to be dynamically shifted alphabetically based on its position, without altering the surrounding prefix or suffix.
Observed behavior
The goal is to extract the text before a delimiter, shift the target character's ASCII code by a specific number, and append the remaining text string correctly.
Before you start

Ensure your dataset follows a consistent structure and uses a uniform delimiter, such as a hyphen, before applying advanced text manipulation formulas.

Solution 1Recommended

Use Text Functions to Extract and Shift Characters

Combine multiple text functions to dynamically locate, modify, and reassemble specific parts of a structured string.

This method is ideal for structured data where a specific character after a delimiter needs to be shifted alphabetically. It uses the CODE function to get the numeric ASCII value of a character, adds a number to shift it, and converts it back to a letter using the CHAR function.

1
Select a Target Cell

Click on an empty cell where you want the modified text to appear, for example, cell B2.

2
Enter the Formula

Type the following formula: =LEFT(A2,FIND("-",A2))&CHAR(CODE(MID(A2,FIND("-",A2)+1,1))+2)&MID(A2,FIND("-",A2)+2,10). Replace 'A2' with your actual data cell if different.

3
Apply and Fill Down

Press Enter to see the result. If you have multiple rows of data, click and drag the fill handle at the bottom-right corner of the cell to apply the formula down the column.

Use Text Functions to Extract and Shift Characters
Formula Breakdown: The LEFT function keeps the prefix intact, CHAR(CODE(...)+2) shifts the target letter by two alphabetical positions, and the final MID appends the rest of the text.
Powerful Spreadsheet Editor

Easily Manipulate Text Data in WPS Spreadsheet

WPS Spreadsheet fully supports advanced text manipulation functions like LEFT, MID, CHAR, and CODE. You can seamlessly manage, edit, and analyze structured text data with an intuitive interface.

  1. 1. Open WPS Spreadsheet: Launch WPS Office and open your workbook containing the text data.
  2. 2. Insert the Formula: Select the target cell, click on the formula bar, and paste your text manipulation formula.
  3. 3. Fill the Column: Double-click the fill handle on the cell's bottom-right corner to automatically process all your structured text strings.
Fully compatible with Microsoft Excel formulas and .xlsx file formats.Lightweight software that processes complex data arrays and formulas quickly.Includes a rich library of built-in text functions for dynamic data manipulation.Completely free to use with a familiar, user-friendly tabbed interface.
microsoft office alternative - wps office

Frequently Asked Questions

How does the CHAR and CODE combination work in spreadsheet formulas?

The CODE function converts a character into its corresponding ASCII numeric value (e.g., 'a' is 97). By adding a number to this value and wrapping it in the CHAR function, you can shift the letter alphabetically (e.g., CHAR(97+2) returns 'c').

Can I replace text without using complex formulas?

Yes, for static replacements, you can use the built-in Find and Replace feature (Ctrl+H) or the simple SUBSTITUTE function. Complex formulas are only needed when the replacement depends on dynamic rules, like shifting a letter's position.

What if my text delimiter is not a hyphen?

If your data uses a different delimiter, such as an underscore or a comma, simply replace the hyphen ('-') inside the FIND function of the formula with your actual delimiter character, making sure it remains enclosed in quotation marks.