List all staff names that worked under a manager on a certain date

surkdidat

Well-known Member
Joined
Oct 1, 2011
Messages
595
Office Version
  1. 365
I have a list of 20,000 employs with a store number and their join and end date.

On another sheet I have a list of managers, with their end date.

What I need to do is have a spreadsheet that will list the managers name, with and end date, and I need to know every member of staff that worked there on their last day.

So, on the date the manager leaves, the staff member must have started that day or before, and still be at the store, or have left on or after the day the manager leaves.

The results could turn up 1 employee or 20 employees.

I hope my example in output makes sense (and the dates match up as they should do!!)

Employee List
A1- Employee NumberB1 - Employee NameC1 - Store NumberD1 - Start DateE1 - End Date
001Richard100031/01/202431/12/9999
002James100001/05/202431/12/9999
003Jeremy100028/01/202405/06/2024
004Steve100004/02/202312/12/2023
005Katie100101/01/202331/12/9999
006Olivia100201/02/202328/02/2023
007Laila100214/03/202431/12/9999
008Ellie100201/01/202314/03/2023
009Jimmy100201/01/202316/03/2023

Output

A1 - Manager NameB1 - Manager StoreC1 - Manager Leave DateD1 - Employee 1E1 - Employee 2F1 - Employee 3G1 - Employee 4
Andy100002/05/2024RichardJamesJeremy
Lee100215/03/2023LailaJimmy
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
How about
Fluff.xlsm
ABCDEFG
1A1 - Manager NameB1 - Manager StoreC1 - Manager Leave DateD1 - Employee 1E1 - Employee 2F1 - Employee 3G1 - Employee 4
2Andy100002/05/2024RichardJamesJeremy
3Lee100215/03/2023Jimmy
Sheet1
Cell Formulas
RangeFormula
D2:F2,D3D2=TOROW(FILTER(Sheet2!$B$2:$B$100,(Sheet2!$D$2:$D$100<=C2)*(Sheet2!$E$2:$E$100>=C2)*(Sheet2!$C$2:$C$100=B2)))
Dynamic array formulas.
 
Upvote 0
How about
Fluff.xlsm
ABCDEFG
1A1 - Manager NameB1 - Manager StoreC1 - Manager Leave DateD1 - Employee 1E1 - Employee 2F1 - Employee 3G1 - Employee 4
2Andy100002/05/2024RichardJamesJeremy
3Lee100215/03/2023Jimmy
Sheet1
Cell Formulas
RangeFormula
D2:F2,D3D2=TOROW(FILTER(Sheet2!$B$2:$B$100,(Sheet2!$D$2:$D$100<=C2)*(Sheet2!$E$2:$E$100>=C2)*(Sheet2!$C$2:$C$100=B2)))
Dynamic array formulas.
Thanks Fluff, that works perfectly with clean data. One thing this has thrown up in the data quality is there are records where the same manager could be listed as "Store Manager" or "Area Manager" for example, - is there a way of adapting the above formula if the name already appears in that row to skip it? (If not, don't worry, I can find a manual workaround (as the manager types are different, "Remove duplicates" doesn't work 100%, as the manager could also be at a different store number, so cannot do it by name alone, or by manager and title.....
 
Upvote 0
Can you provide some sample data.
 
Upvote 0
Apologies, I got the details the wrong way around. What I meant is in the below table "Richard Jones" has two titles as the same store "Assistant" and "General assistant". All other details are the same, as its the same employee, he has just been set up twice. This obviously needs to be corrected int he data side, but can the formula be adapted so where it sees "Richard Jones" as employee 001 at store 1000 (ie all other details suggest its a duplicate record, his second record is skipped and so in the output table below Richard only shows up once. No biggie if not.

Employee List
A1- Employee NumberB1 - Employee NameC1 - PositionD1 - Store NumberE1 - Start DateF1 - End Date
001Richard JonesAssistant100031/01/202431/12/9999
001Richard JonesGeneral assistant100031/01/202431/12/9999
002JamesAssistant100001/05/202431/12/9999
003JeremyAssistant100028/01/202405/06/2024
004SteveAssistant100004/02/202312/12/2023
005KatieAssistant100101/01/202331/12/9999
006OliviaAssistant100201/02/202328/02/2023
007LailaAssistant100214/03/202431/12/9999
008EllieAssistant100201/01/202314/03/2023
009JimmyAssistant100201/01/202316/03/2023

Output

A1 - Manager NameB1 - Manager StoreC1 - Manager Leave DateD1 - Employee 1E1 - Employee 2F1 - Employee 3G1 - Employee 4
Andy100002/05/2024Richard JonesRichard JonesJamesJeremy
Lee100215/03/2023LailaJimmy
 
Last edited by a moderator:
Upvote 0
How about
Excel Formula:
=TOROW(UNIQUE(FILTER(Sheet2!$B$2:$B$100,(Sheet2!$D$2:$D$100<=C2)*(Sheet2!$E$2:$E$100>=C2)*(Sheet2!$C$2:$C$100=B2))))
 
Upvote 0

Forum statistics

Threads
1,224,259
Messages
6,177,482
Members
452,782
Latest member
ZCapitao

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top