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.


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.


Count times a word appears in an excel cell

If a word appears several times in a cell which needed to be count, usually, you may count them one by one. But if the word appears hundreds of times, the manually counting is troublesome. The Count times a word appears function in Kutools for Excel's Formula Helper group can quickly calculate the count of times a word appear in a cell. Free trial with full features in 30 days!
 
Kutools for Excel: with more than 300 handy Excel add-ins, free to try with no limitation in 30 days.

> 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 300 handy functions, makes your jobs more easier. 

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

1. Select a cell you want to return the result and click Kutools > Formula Helper > Formula Helper . See screenshot:

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

1) Select Lookup from the drop-down list of Formula Type section;

2) Choose Find where the character appear Nth in a string in Choose a formula section;

3) Select the cell which contains the string you use, then type the specified character and nth occurrence in to the textboxes in the Arguments input section.

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


The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
kte tab 201905

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!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Roo Payne · 1 years ago
    "Substitute" lets you find the Nth occurrence of a term, so combine it with "find" as follows (where 5=5th occurrence):

    =FIND(CHAR(1),SUBSTITUTE(A1,"c",CHAR(1),5))
    • To post as a guest, your comment is unpublished.
      SysAdminBen · 1 years ago
      This is the correct answer! please replace this whole article with this one line of code.....
  • To post as a guest, your comment is unpublished.
    AnnihilatorDJ · 2 years 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.
      nmcfarland5@gmail.com · 1 years ago
      Absolutely agree. The +2, or +3 etc.....entirely depends on the spacing between the n and (n+1) occurences of "c". Thus you would have to manually adjust for every cell if you were trying to copy this formula down a column for instance. Essentially the same as manually counting.


      Ex. Let's try to find the 4th occurrence of "c" in cell A1 using the provided formula. Per the article we should use +3 in our nested FIND function to find the 4th occurrence.


      Text in Cell A1:

      "cab car abc cole cube"

      Manually counting, the 4th occurrence is the "c" in cole in the character position of 13.


      =FIND("c",A1,FIND("c",A1)+3)

      The nested function, FIND("c",A1) will find the first occurrence of "c" in position 1.

      Therefore,

      FIND("c",A1)+3 = 1+3 = 4

      Plugging that back into our formula,

      =FIND("c",A1,FIND("c",A1)+3) = FIND("c",A1,1+3) = FIND("c",A1,4)

      This new formula will look for the first occurrence of "c" beginning from character position 4. The 4th character in the string is the space just after cab.

      Therefore, the formula will find the "c" in car and return the value of 5 for our formula. As we know from manually counting we are looking for 13 as the output.
    • To post as a guest, your comment is unpublished.
      Sunny · 2 years ago
      The firs formula works correct in my version, in the note, it has explained how to find the third or forth or nth "c".

      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.
      • To post as a guest, your comment is unpublished.
        AnnihilatorDJ · 2 years ago
        Try to find out the position of the second c with the first sentence of my above comment as the string using the first formula. You'll get to know how correct it is!
  • To post as a guest, your comment is unpublished.
    n.k.mandadapu@gmail.com · 2 years 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 · 2 years 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 · 2 years 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 · 3 years 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 · 3 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 · 3 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).
  • To post as a guest, your comment is unpublished.
    jr · 5 years ago
    Try this:
    =INDEX(SMALL(IF(MID(A1,MATCH(ROW(INDIRECT(1&":"&LEN(A1))),ROW(INDIRECT(1&":"&LEN(A1))),0),1)="c",MATCH(ROW(INDIRECT(1&":"&LEN(A1))),ROW(INDIRECT(1&":"&LEN(A1))),0),""),MATCH(ROW(INDIRECT(1&":"&LEN(A1)-LEN(SUBSTITUTE(A1,"c","")))),ROW(INDIRECT(1&":"&LEN(A1)-LEN(SUBSTITUTE(A1,"c","")))),0)),[b]2[/b])
    where "c" is the character required and [b]2[/b] is the position. Note this is an array formula.
    • To post as a guest, your comment is unpublished.
      jr · 5 years ago
      this is simpler:
      =INDEX(SMALL(IF(MID(A1,ROW(INDIRECT(1&":"&LEN(A1))),1)="c",ROW(INDIRECT(1&":"&LEN(A1))),""),ROW(INDIRECT(1&":"&LEN(A1)-LEN(SUBSTITUTE(A1,"c",""))))),2)
  • To post as a guest, your comment is unpublished.
    Geep · 6 years ago
    After some playing around I got the following to find the third instance of X and return the position number.

    =FIND("X",A1,(FIND("X",A1,FIND("X",A1,1)+1))+1)

    The VBA module gets my vote though. Much easier to remember
    • To post as a guest, your comment is unpublished.
      Matthew · 6 years ago
      Sure, but you could nest formulae in the "instance number" parameter indefinitely. Formula 2 obviates VBA, making it the best all-round solution.
  • To post as a guest, your comment is unpublished.
    Mohit Sharma · 6 years ago
    Dear All,

    I want to select a particulate string form a cell
    Example:-

    My Name is Mohit

    i want to return any value Like mohit, is, Name, My using a function.
    is there any Function or not
    • To post as a guest, your comment is unpublished.
      DdW · 6 years ago
      I think there is no specific function for that, since Excel is not built to handle lists of values in one cell. You can build the function yourself by combining the functions mentioned above with LEFT() and RIGHT(). Or you could use VBscripting of course.
  • To post as a guest, your comment is unpublished.
    DdW · 6 years ago
    Find Formula 1 won't work. The third parameter of the Find function is the index where the search should begin (as in: the first x characters of the string are ignored). i.e. if a string contains the letter c at indices 1, 5 and 10 the results are as follows:
    =FIND("c",A1,1) will find the first c
    =FIND("c",A1,2) through =FIND("c",A1,5) will find the second c
    =FIND("c",A1,6) through =FIND("c",A1,10) will find the third c.
    anything above won't find anything.
    • To post as a guest, your comment is unpublished.
      skyyang · 6 years ago
      Thank you for finding out this mistake, i'm sorry the formula1 is wrong, the correct formula should be [b]=FIND("c",A1,FIND("c",A1)+2)[/b] ,and if you want to find the first letter "c", you just need to change the 2 to 0.
      • To post as a guest, your comment is unpublished.
        sanjeev · 4 years ago
        I am able to find second instance but what about 3rd, 4th and 'n'th. I am not able to get 3rd instance (as well as 4th). I have data which contains 50 to 60 instances. so what should I do?
        • To post as a guest, your comment is unpublished.
          Matthew · 4 years ago
          sanjeev, as I said two years ago, use Formula 2:

          =FIND(CHAR(1),SUBSTITUTE("LOOK_IN","LOOK_FOR",CHAR(1),INST_NUM))

          Where LOOK_IN is the string (or cell) you're searching in;
          LOOK_FOR is the string you're searching for; and
          INST_NUM is the integer instance of LOOK_FOR that you want to identify.

          Hence, =FIND(CHAR(1),SUBSTITUTE("HELLO WORLD","L",CHAR(1),3) will return 10 (the position of the third "L").
      • To post as a guest, your comment is unpublished.
        Matthew · 6 years ago
        As DdW indicates, the '+2' or '+0' or what-have-you is a 'hard-coded' character position; you'd have to already know where the "c" was, in order to find it.

        Formula 2 is spot-on, though: SUBSTITUTE the nth instance of your target string for a unique character that won't otherwise appear in the rest of the text, then FIND that unique character.