If two cells are the same as another row, copy paste 6 cells from that row and replace the null ones

Hi - I have an excel reader with an employee ID, department, his/her direct manager name, and the maximum amount of 6 levels of managers on top of that employee with L0 being the big boss, all the way down to that employee (L6 is the maximum). The name of the employee does not show in those levels (It stops at the direct manager name)

This excel is joined with another excel with employee IDs as well. The Idea is to attach the columns L0 to L6 for each matching employee ID.

The problem is, if the joined excel with the L0 To L6 does not have that employee ID in the first place, then L0 to L6 come out at null. This can happen with new employees and ones that have left the company.

What I need to do is, is to find a logic to automate all new names and old ones, to populate L0 to L6, because at the end of the day, teams are static and didn’t change. So in summary, the logic should say:

If L0 to L6 is empty, Insert same L0 to L6 from a row that shows same Manager Name and Department .

In the example below, it should copy Yellow in L0, Green in L1, Black in L2, Orange in L3 and Red in L4 in row2 because Manager and Department is the same as in row3. (Red and Sales)

I would appreciate any help please. thank you