find nth occurrence and return values

moira

New Member
Joined
Sep 16, 2004
Messages
22
Hello! I would like to find the Nth occurrence of a string and return the 3 characters that follow. For example, find the 7th occurrence of the string "ABC" and return the 3 characters that follow - - such as dog. Thank you in advance!
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Here is one way.

Book1
H
21dog
22ABC red ABC blue ABC purple ABC green ABC yellow ABC pink ABC dog ABC cat ABC lizard
Sheet1
Cell Formulas
RangeFormula
H21H21=MID(H22,FIND("~",SUBSTITUTE(H22,"ABC","~",7))+4,3)
 
Upvote 0
Hi moira,

Something like this might work...
Book1.xlsx
K
227
23ABCDEFABCOLIABCGHIABCDEFABCDEFABCDEFABCLOLABCKLPABCPOSABCDEF
24LOL
Sheet19
Cell Formulas
RangeFormula
K24K24=MID(K23,SEARCH("|",SUBSTITUTE(K23,"ABC","|",K22),1)+3,3)

Hope that helps,

Doug
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

If you have 365 another option
Excel Formula:
=LEFT(TEXTAFTER(A2,"ABC",7),3)
 
Upvote 0

Forum statistics

Threads
1,215,097
Messages
6,123,076
Members
449,094
Latest member
mystic19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top