Testing with (Barry's) formulas
For the first one, it seems to be grabbing the last several digits of the data, which doesn't work, as the finish codes vary in length (0, PB, 1WH, for example).
The "first one" is a pair of formulas, one in column B, the second in column C.
The first gets the last three 'digits' characters from the full code in column A, and uses SUBSTITUTE to remove any dashes that are included in those three characters. It should return the correct finish code for any pattern (two characters, sometimes three, always immediately preceded by a dash, always at the end of the full code) described to this point in the discussion. It will not work with a one character finish code (unless it is immediately preceded by two consecutive dashes), a two character finish code not immediately preceded by a dash, or a finish code with more than three characters. You cannot get a precise answer without asking a precise question.
I also can't get the second formula to show anything but 'not found'.
The second and third ones both seem to always give 'not found', no matter what's in cell A2.
"not found" is the "IFERROR" result. If there is an error in the formula, or resulting from the formula shown here as "formula":
IFERROR(formula,"not found")
Then the result will be "not found".
IFERROR is used to trap an expected error—the formula not being able to find the searched value in the list of finish codes in column A of the table Wayne and I named 'Code list' and you have named 'Finish Codes'.
For the third one, this is the formula I have in cell B2:
And in C2:
The third example does not use column C.
The second example des not use column C.
The second, as noted above, replaces the reference to B2 in the formula that was (in the first example) in C2, with the formula that had been in B2, where it had created the finish code that reference had been used to collect.
The third is a modification of the second. It checks the content of A2, and suppresses calculation by the rest of the formula if A2 is empty.
Your version: IF(LEN(A2)<1,"",IFERROR(VLOOKUP(SUBSTITUTE(RIGHT(A2,3),"-","",occurrence),Finish Codes::A:B,2,FALSE),"not found"))
Supplied version: IF(LEN(A2)<1,"",IFERROR(VLOOKUP(SUBSTITUTE(RIGHT(A2,3),"-",""),Code list::A:B,2,FALSE),"not found"))
I see only the two differences shown in bold, neither of which seems significant. occurence is an optional argument used to specify a specific instance of the search value ( "-" in this case) is to be replaced. It shows in the copy of the formula only because we have both omitted specifying a value for it (and I deleted it from the pasted copy in my post).
Finish Codes and Code list differ only because you and I have given different names to the lookup table.
As there do not appear to be any syntax errors in your formula, the only reasons for a 'not found' result appear to be:
your lookup table is not named Finish Codes, spelled exactly as in the formula OR
the formula is looking for a finish code that is not in column A of the lookup table.
Regards,
Barry