I'm just about to head off into the sunset but I was thinking that perhaps you could use the INDEX/MATCH function wrapped in the MAX function. Something like:-
assuming the values are in Columns A, B, & C.
If there isn't a matching value, it should return N/A in the column in which you place the formula. But I'm not sure if it could handle and give the right return if there is a value in the first column with two matches in the second column (such as the value "M").
Have a fiddle with it. You never know.
Formulae are not a strong point with me so where is Mazzaropi when you need him?!!?