Look up - while loop

djxela

New Member
Joined
Sep 22, 2011
Messages
6
Hi all,


I have a list of of employees with a unique number assigned to each one.
Then i have a separate list with the entire list of employees and their 1Up manager as well as their 2 Up manager.


I need a script that will look up that employee on the list, finds their 1 UP manager, checks that 1 Up manager to see if the Job Band is A otherwise keep going and look up their managers manager until it finds the person that has a Job Band A and returns that employee ID as well as on a separate column return the employee ID of the manager before him
So basically i am looking to see who the top two managers are.


See below example if we look for Stacey Party the top Manager would be Alex Burn as his Job Band is A and then 2nd top manager is Mike Freespirit


[TABLE="width: 1010"]
<colgroup><col><col><col><col><col><col><col><col><col><col></colgroup><tbody>[TR]
[TD]Employee No[/TD]
[TD]Last Name[/TD]
[TD]First Name[/TD]
[TD]Job Band[/TD]
[TD]1-up employee no.[/TD]
[TD]1-up manager name[/TD]
[TD]2-up employee no.[/TD]
[TD]2-up manager Name[/TD]
[TD]Top Manager[/TD]
[TD]2nd top Manager[/TD]
[/TR]
[TR]
[TD]37975696[/TD]
[TD]Party[/TD]
[TD]Stacy[/TD]
[TD]3i[/TD]
[TD]49114594[/TD]
[TD]John Smith[/TD]
[TD]46741146[/TD]
[TD]Nikita Walter[/TD]
[TD]46740709[/TD]
[TD]37224331[/TD]
[/TR]
[TR]
[TD]49114594[/TD]
[TD]John[/TD]
[TD]Smith[/TD]
[TD]2[/TD]
[TD]46741146[/TD]
[TD]Nikita Walter[/TD]
[TD]37224331[/TD]
[TD]Mike Freeespirit[/TD]
[TD]46740709[/TD]
[TD]37224331[/TD]
[/TR]
[TR]
[TD]46741146[/TD]
[TD]Walter[/TD]
[TD]Nikita[/TD]
[TD]1[/TD]
[TD]37224331[/TD]
[TD]Mike Freeespirit[/TD]
[TD]46740709[/TD]
[TD]Alex Burn[/TD]
[TD]46740709[/TD]
[TD]37224331[/TD]
[/TR]
[TR]
[TD]37224331[/TD]
[TD]Freespirit[/TD]
[TD]Mike[/TD]
[TD]C[/TD]
[TD]46740709[/TD]
[TD]Alex Burn[/TD]
[TD]46516969[/TD]
[TD]Andy Braun[/TD]
[TD]46740709[/TD]
[TD]37224331[/TD]
[/TR]
[TR]
[TD]46740709[/TD]
[TD]Burn[/TD]
[TD]Alex[/TD]
[TD]A[/TD]
[TD]46516969[/TD]
[TD]Andy Braun[/TD]
[TD]0[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,224,816
Messages
6,181,139
Members
453,021
Latest member
Justyna P

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