How to Replace Partial Text in an Excel Cell Based on Its Value
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'.

- 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.
Ensure your dataset follows a consistent structure and uses a uniform delimiter, such as a hyphen, before applying advanced text manipulation formulas.
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.
Click on an empty cell where you want the modified text to appear, for example, cell B2.
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.
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 the SUBSTITUTE Function for Static Replacements
If you know the exact text you want to replace and it doesn't require dynamic alphabetical shifting, the SUBSTITUTE function provides a much simpler approach.
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. Open WPS Spreadsheet: Launch WPS Office and open your workbook containing the text data.
- 2. Insert the Formula: Select the target cell, click on the formula bar, and paste your text manipulation formula.
- 3. Fill the Column: Double-click the fill handle on the cell's bottom-right corner to automatically process all your structured text strings.

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.




