How to replace nth/all occurrences of a character in string in Excel?
For example, there is a string in a cell, and you need to replace the third “o” in the string, how could you quickly solve it? And what if replacing all occurrence of this characters in the string? This article will show you the method.
This method will introduce the easy SUBSTITUTE function to replace the nth or all occurrences of a certain character in a cell in Excel.
Select a blank cell, and type the formula =SUBSTITUTE(A1,"o","_",3) into it, and press the Enter key. See screenshot:
And now you will see the third “o” is replaced. See screenshot:
(1) In the formula =SUBSTITUTE(A1,"o","_",3), A1 is the cell you will replace string, o is the specified character you will replace, _ is the specified character you will replace with, and 3 means you will replace the 3rd occurrence of “o”.
(2) If you need to replace all occurrences of “o” with underline in the Cell A1, please apply this formula =SUBSTITUTE(A1,"o","_").
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!