# Thread: Finding the Nth occurance of a character in a stri (Excel 2003)

1. ## Finding the Nth occurance of a character in a stri (Excel 2003)

I have a list of items which contain hyphens to separate Division-Department-JobNumber-JobTitle.
I would like to parse out the Job Title from each record in the list but I can't figure out how to get FIND to return the location of the third occurrence of the hyphen to use as a starting point for RIGHT.
I got as far as =RIGHT(F36,LEN(F36)-FIND("-",F36,1)) which strips out the division, but I thought I should see if there's an easier way to accomplish this.

2. ## Re: Finding the Nth occurance of a character in a stri (Excel 2003)

A not so pretty way:
=MID(A1,FIND("-",A1,FIND("-",A1)+1)+1,99)

I've seen a better method - I'm looking for it....

3. ## Re: Finding the Nth occurance of a character in a stri (Excel 2003)

Hi Arcturus16a,

If the string you want to search is in A1, the substring you want to find is in A2 and the substring instance you want to find is in A3, then the following formula will return the position where the nth occurrence of the substring being searched for starts:
=FIND("",SUBSTITUTE(A1,A2,"",A3))
Similarly, if you want to find the starting position of the 3rd '_':
=FIND("",SUBSTITUTE(A1,"_","",3))
There is nothing particularly special about the use of ASCII 135 (ie ), except that its unlikely to appear in any 'normal' text string.

4. ## Re: Finding the Nth occurance of a character in a stri (Excel 2003)

You could also use Text to Columns using the hyphen as the delimiter to quickly break the data out into 4 columns, if that helps.

5. ## Re: Finding the Nth occurance of a character in a

F36 : Division-Department-JobNumber-JobTitle

Formula to parse out the JobTitle :

1] =RIGHT(F36,LEN(F36)-FIND("",SUBSTITUTE(F36,"-","",3)))

or

2] =TRIM(RIGHT(SUBSTITUTE(F36,"-",REPT(" ",50)),50))

6. ## Re: Finding the Nth occurance of a character in a

Amazing! Well, "Amazing!" to me anyway, probably not to you . All these solutions work very well.
MBARRON's solution =MID(A1,FIND("-",A1,FIND("-",A1)+1)+1,99) parses out the Div-Dept leaving the Job Code and Job Title
MACROPOD's =FIND("",SUBSTITUTE(A1,"-","",3)) tells me the exact position of the Nth (3rd) hyphen
RORY I didn't want to use the Text to Columns because of the extra steps required. But since I'm showing this file to a trainee I wont forget to demonstrate it's use.
BOSCO_YIP'S solutions produced different results in my list. The second solution found records where our HR department had added a hyphen to designate "- FT" and "- PT" (Full/Part time employees). But it was the first solution that did the whole job for me (for some reason I needed to TRIM those results. Extra space in one of the records).

Thanks to you all for your help. I'll be sure to share this lesson here at work.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•