That is slick. It can be fooled, however, in the unlikely event any instance of the
string you're looking for happens to have the instance number following it. This might
happen in numbers combining alpha characters and digits (like part numbers). For
example:
A1: CC3C
A2: C
A3: 3
It finds the second C, and returns 2.
You can use this modification:
=FIND(A2&"|"&A3,SUBSTITUTE(A1,A2,A2&"|"&A3,A3))
You use a character known never to appear in the data, such as the pipe character in this
example. The added character can be an unlikely string, like !#$%.
=FIND(A2&"!#$%"&A3,SUBSTITUTE(A1,A2,A2&"!#$%"&A3,A3))
This unlikely string occurs only when Sarge is swearing (and beating the stuffing out of
Beetle).
--
Earl Kiosterud
www.smokeylake.com
Note: Some folks prefer bottom-posting.
But if they bottom-post to a reply that's
already top-posted, the thread gets messy. When in Rome...
-----------------------------------------------------------------------
macropod said:
Hi Tom,
Suppose 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(A2&A3,SUBSTITUTE(A1,A2,A2&A3,A3))
Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------
One can use SEARCH() or FIND() to find a string within another. And, if you wanted to
find the first few, you can nest the calls and it probably works ok. But, this has its
limits. Lets say you wanted to find the 10th occurance of a particular string within a
string, now the formula gets really hairy, if you nest.
Any clever ideas out there to find the n-th occurance of a string within another?
Thanks,
tom