Skip to main content

Find nth occurrence of character in a cell

If you need to find and get the position of nth occurrence of a specific character from a text string as below screenshot shown, there is no direct function for you to solve this task in Excel. This article, I will talk about using a formula which combines the FIND and SUBSTITUTE functions to deal with it.


Find the position of nth occurrence of a specific character in a cell

For example, I have a list of text strings in column A, and now, I want to get the position of the specific characters in column B which appears the nth occurrences, how to solve it?

In Excel, you can combine the FIND and SUBSTITUTE functions for solving this job, the generic syntax is:

=FIND(CHAR(160),SUBSTITUTE(text,char,CHAR(160),N))
  • text: The text string or cell value that you want to use.
  • N: The nth occurrence of a character that you want to get position.

1. Please enter or copy the below formula into a blank cell where you want to put the result:

=FIND(CHAR(160),SUBSTITUTE(A2,B2,CHAR(160),C2))

Note: In the above formula, A2 is the cell contains the text string that you want to use, B2 is the specific character that you want to find, and C2 is the nth number that you want to get the position of the specific character based on.

2. And then, drag the fill handle down to the cells that you want to apply this formula, and you will get the result as you need:


Explanation of the formula:

SUBSTITUTE(A2,B2,CHAR(160),C2): The SUBSTITUTE function will replace the 3rd occurrence of the character “o” with the char(160) character. It returns the text string as following screenshot shown:

FIND(CHAR(160),SUBSTITUTE(A2,B2,CHAR(160),C2)): This FIND function is used to look for the position of the char(160) character within the new text string returned by the SUBSTITUTE function.


Relative functions used:

  • FIND:
  • The FIND function is used to find a string within another string, and returns the starting position of the string inside another one.
  • SUBSTITUTE:
  • The SUBSTITUTE function replaces text or characters within a text string with another text or characters.

More articles:

  • Extract Nth Word From Text String In Excel
  • If you have a list of text strings or sentences, now, you want to extract the specific nth word from the list as below screenshot shown. This article, I will introduce some methods for solving this job in Excel.
  • Extract Last Line Of Text From A Multi-Line Cell
  • To extract the last line of text from a text string which is separated by line breaks, normally, there is no direct way for you to solve this. This article, I will introduce a formula to deal with this task in Excel.

The Best Office Productivity Tools


Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)

  • One second to switch between dozens of open documents!
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Edge and Firefox.
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations