Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or
0
0
0
s2smodern

How to find nth occurrence (position) of a character in text string in Excel?

For example, there is a long sentence in Cell A1, see the following screenshot. And now you need to find the 3rd occurrence or position of Character "c" from the text string in Cell A1. Of course, you can count the characters one by one, and get the exact position result. However, here we are going to introduce some easy tips to find the nth occurrence or position of specific character from text string in a cell.


Count times a word(count times of a specific word appears in a single cell or a range .)

doc formula 1

Find nth occurrence (position) of a character in a Cell with Find formula


There are two Find formulas can help you find the nth occurrence or position of specific character from text string in a cells quickly.

The following formula will show you how to find the 3rd occurrence of "c" in Cell A1.

Find Formula 1

In a blank cell, enter the formula =FIND("c",A1,FIND("c",A1)+2).

doc-find-nth-position-of-text-string2

And then press the Enter key. The position of the third letter “c” has been displayed.

Note: You can change the 2 in the formula based on your needs. For example, if you want to find the fourth position of "c", you can change the 2 to 3. And if you want to find the first position of "c", you shuold change 2 to 0.

Find formula 2

In a blank cell, enter the formula =FIND(CHAR(1),SUBSTITUTE(A1,"c",CHAR(1),3)), and press Enter key.

Note: The "3" in the formula means the third "c", you can change it based on your needs.


> Find nth occurrence (position) of a character in a Cell with VBA

Actually, you can apply the VB macro to find nth occurrence or position of a specific character in one cell easily.

Step 1: Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.

Step 2: Click Insert > Module, and paste the following macro in the Module Window.

VBA: Find the nth position of a charater.

Function FindN(sFindWhat As String, _
sInputString As String, N As Integer) As Integer
Dim J As Integer
Application.Volatile
FindN = 0
For J = 1 To N
FindN = InStr(FindN + 1, sInputString, sFindWhat)
If FindN = 0 Then Exit For
Next
End Function

Step 3: Now if you want find the exact occurrence of position of third "c" in Cell A1, please enter the formula of =FindN("c",A1,3), and press the Enter key. Then it will return the exact position in the specific cell at once.


Find nth occurrence (position) of a character in a Cell with Kutools for Excel

If you like neither of formula and VBA, you can try a handy tool – Kutools for Excel, with its Formula groups, you can find a utility – Find nth occurrence of a character to quickly return the nth position of a character in a cell.

Kutools for Excel, with more than 120 handy Excel functions, enhance your working efficiency and save your working time.

After free installing Kutools for Excel, please do as below:

1. Select a cell you want to return the result and click Kutools > Formulas > Find nth occurrence of a character. See screenshot:

doc kutools 1

2. Then in the popping Formula Helper dialog, do as below:

doc find position of text string 4
1) Select the cell you want to find out a specific character from to the String textbox;



2) Type the character you want to find around with double quotations “” into Character textbox;



3) Type the nth occurrence of character into Nth occurrence textbox.

3. Click Ok. And you get the position of nth occurrence of a character in a string.

doc find position of text string 5

pay attention1If you are interested in this addi-in, download the 60-days free trial.

Count Weekdays/Weekends/Specific Weekday between two dates 

Supposing you have a two given dates, one is start date and another is end date, how can you quickly count the workday, weekend or a specific weekday such as Monday between thses date range? If you are interesed, you can try on Kutools for Excel's Count weekdays/weekends/specific weekday utilities.
doc count weekday weekend

Recommended Productivity Tools

Office Tab

gold star1 Bring handy tabs to Excel and other Office software, just like Chrome, Firefox and new Internet Explorer.

Kutools for Excel

gold star1 Amazing! Increase your productivity in 5 minutes. Don't need any special skills, save two hours every day!

gold star1 200 New Features for Excel, Make Excel Much Easy and Powerful:

  • Merge Cell/Rows/Columns without Losing Data.
  • Combine and Consolidate Multiple Sheets and Workbooks.
  • Compare Ranges, Copy Multiple Ranges, Convert Text to Date, Unit and Currency Conversion.
  • Count by Colors, Paging Subtotals, Advanced Sort and Super Filter,
  • More Select/Insert/Delete/Text/Format/Link/Comment/Workbooks/Worksheets Tools...

Screen shot of Kutools for Excel

btn read more      btn download     btn purchase

Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
People in conversation:
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Nitish · 3 days ago
    The first formula is completely useless and wrong but it works just correct for this example as the first and second "c"s are adjacent. The correct formula is:


    For 2nd occurence -
    =FIND("c",A1,FIND("c",A1)+1)

    For 3rd occurence -
    =FIND("c",A1,FIND("c",A1,FIND("c",A1)+1)+1) and so on...
  • To post as a guest, your comment is unpublished.
    Nagendra Kumar · 1 months ago
    Hello all,

    I have a text in an Excel cell " BY TRANSFER-NEFT*HDFC0000001*N08745987123546*J0032331*KUMAR--"

    I need a function to extract just "N08745987123546"

    Thanks
    • To post as a guest, your comment is unpublished.
      Sunny · 1 months ago
      Hello, do you want to extract the numbers after No and the number of numbers are fixed? If so, you can use Kutools for Exccel's Extract text function, type No????to extract.
  • To post as a guest, your comment is unpublished.
    KUMAR · 1 months ago
    HI ALL,
    I have a text in an Excel cell " BY TRANSFER-NEFT*HDHC0065431*N053112345624801*K0038331*krishna--"
    I need a function to extract just "N053112345624801"
  • To post as a guest, your comment is unpublished.
    kamil · 10 months ago
    Formula 1 doesn't work on fourth, fifth, sixth etc. so (+3,4,5) will always show third position of letter "c" which is 19 second formula is working though.
  • To post as a guest, your comment is unpublished.
    Philip Oyetunde · 1 years ago
    Hello all,

    I have a text in an Excel cell "23 floyd lane, longville,KN 14564"

    I need a function to extract just "longville"

    Thanks
    • To post as a guest, your comment is unpublished.
      Rukt · 1 years ago
      If you must use a function, try: =TRIM(MID(A1,SEARCH(",",A1)+1,SEARCH("!@#",SUBSTITUTE(A1,",","!@#",2))-SEARCH(",",A1)-1))

      Otherwise, you might consider Data > Text to Columns > Delimited (using a comma as the separator).