A single formula that addresses the end requirement might be possible, but it would be a nasty formula indeed. A couple simple formulae and short workflow might suffice:
In a blank column e.g. M2
write formula
=VLOOKUP(J2,K:K,1,FALSE)
and fill down as far as values go in column J
. The result will be #N/A
wherever there is no match--these are the people with no picture. VLOOKUP
will ignore case differences, and the formula doesn't care if the matching name is on a different row.
Since you want to order by surname you will need a way to get that information out of the [First Last]
format. In another blank column, write formula
=MID(J2,FIND(" ",J2,1)+1,30)
and again fill down.
The whole thing can now be sorted on two keys: primary on the VLOOKUP
column, and secondary on the surname column. The #N/A
people will sort to the bottom of the list, making the full names easy to copy off for further processing.
Edit: In pictures:
Step 1: I added surnames because that's the real use case. Note there are two different people named "Alex". Now add the formulae I gave above (shown in red here):
Step 2: Sort the range as described above.
Step 3: The people shaded in green are not in the PT
column. We know this because the lookup column returned #N/A
. Also, their names are sorted by surname.
Hope this helps to clarify.