This part
(LEN(A1)-LEN(SUBSTITUTE(A1,"abc","")))/LEN("abc")
will return how many substrings of "abc" there are in the string in A1,
thus if you want the last occurrence of "abc" the above formula will return
the last occurrence number
len(a1) will count the characters when substituted with null strings "" and
subtracted from
the total -LEN(SUBSTITUTE(A1,"abc","")) then divided with the numbers of
substring characters so if the string looks like
adfhabcvbfrabc
the formula will return 2 (6 (abc+abc) characters divided with 3 (abc)
now this part
SEARCH("^^^",SUBSTITUTE(A1,"abc","^^^",
will look for a unique string "^^^" could be anything that you are sure of
will not be
in the string in A1, it replaces the second substring "abc" with "^^^" and
thus can be
found, if there would be 4 substrings
(LEN(A1)-LEN(SUBSTITUTE(A1,"abc","")))/LEN("abc")
then the above will return 4 thus replacing the 4th occurrence of "abc" with
"^^^"
thus returning the number of characters to the first letter of "abc"
so if you want the second last occurrence subtract -1 from this part
(LEN(A1)-LEN(SUBSTITUTE(A1,"abc","")))/LEN("abc")
so
=SEARCH("^^^",SUBSTITUTE(A1,"abc","^^^",((LEN(A1)-LEN(SUBSTITUTE(A1,"abc","")))/LEN("abc"))-1))
will return second but last (make sure there are more than one occurrence or
it will return an error)