I need to extract a string between two other strings where the pattern is almost always the same (it has to be done with a formula and not VBA sadly):
Data structure:
Data Extract Country
12345678 111 Test Test 132433 172282 111 USA 111 ABCD USA
123456 111 Test Test 132433 172282 111 GER 111 AB GER
1231231 222 Test Test 132433 172282 111 JAP 111 A JAP
The problem I'm having is the data to extract is always between the 111 USA 111, however there is in the beginning also a string of "111" so I need to find the second occurrence of 111, except in the case of Japan here where I need to find the first occurrence.
How can I do this dynamically with an Excel formula, tried the following which almost works:
MID(A2,FIND(CHAR(3),SUBSTITUTE(A2,"111",CHAR(3),2))+3,4)