- To post as a guest, your comment is unpublished.· 1 years agoThis is the correct answer! please replace this whole article with this one line of code.....
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 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.|
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).
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.
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.
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 installing Kutools for Excel, please do as below:（Free Download Kutools for Excel Now!)
1. Select a cell you want to return the result and click Kutools > Formulas > Find nth occurrence of a character. See screenshot:
2. Then in the popping Formula Helper dialog, do as below:
3. Click Ok. And you get the position of nth occurrence of a character in a string.
|Kutools for Excel: 300 + functions you must have in Excel, 60-day free trial from here.|
Tabbed browsing & editing multiple Excel workbooks/Word documents as Firefox, Chrome, Internet Explore 10!
You may be familiar to view multiple webpages in Firefox/Chrome/IE, and switch between them by clicking corresponding tabs easily. Here, Office Tab supports similar processing, which allow you to browse multiple Excel workbooks or Word documents in one Excel window or Word window, and easily switch between them by clicking their tabs. Click for free 30-day trial of Office Tab!