Okay, I am giving 2 solutions.
Solution 1 assumes that the number of employees for each machine is consistent (in this case 4 for each machine) Solution 1 results in a longer formula.
Solution 2 does not assume that so requires some manual effort initially. I set up 2 blank spaces between each machine and then copied the first name on the list above to the first blank, and the last name on the list below to the second blank. Then I added a blank space " " after these names so they are (to Excel) different than the original names. (So "John" versus "John "). Solution 2 results in a fairly short formula.
Solution 1: In C2
Formula:
=IFERROR(IF(INDEX(Sheet2!$C$3:$C$23, MATCH(B2, Sheet2!$C$3:$C$23,0)-1)=0, INDEX(Sheet2!$C$3:$C$23, MATCH(B2, Sheet2!$C$3:$C$23,0)+3),INDEX(Sheet2!$C$3:$C$23, MATCH(B2, Sheet2!$C$3:$C$23,0)-1)),"")
In C3
Formula:
=IFERROR(IF(INDEX(Sheet2!$C$3:$C$23, MATCH(B2, Sheet2!$C$3:$C$23,0)+1)=0, INDEX(Sheet2!$C$3:$C$23, MATCH(B2, Sheet2!$C$3:$C$23,0)-3),INDEX(Sheet2!$C$3:$C$23, MATCH(B2, Sheet2!$C$3:$C$23,0)+1)),"")
Then copy that pair of cells and copy them down the page.
[B][/Solution 2:B] In Solution 2, the MATCHs will ignore the names with the spaces after them so things are much simplier. In C2
Formula:
=IFERROR(INDEX(Sheet2!$D$3:$D$26, MATCH(B2, Sheet2!$D$3:$D$26,0)-1),"")
In C3
=IFERROR(INDEX(Sheet2!$D$3:$D$26, MATCH(B2, Sheet2!$D$3:$D$26,0)+1),"")
See attached workbook
Bookmarks