Organizational Hierarchy Issue Vlookup Look Efficient?

mrmmickle1

Well-known Member
Joined
May 11, 2012
Messages
2,461
Having a little issue with something at work. I'm trying to get the "hierarchy level" of an employee based on two fields: EE Name and EE Supervisor.

I have been able to complete the task in a logical manner but am having a little trouble automating it. I was wondering if anyone has any insight on how to go about automating this process. In order to see the logical progression I will post the steps in order. The data starts off with a boss on top. This is the guy that all employees will roll up to. He is defined as Level 0.

Start:

Excel 2010
ABC
1EE NameEE SupervisorLevel
2JohnHead Honcho0
3MattJohn
4JerryMatt
5MathiasJohn
6JonesyMatt
7TrippMathias
8TaylorJonesy
9RileyJonesy
10SarahMeaghan
11MeaghanJohn
Sheet1


Step 1: Identify EE's that role up to John. If #N/A is returned we know they do not....


Excel 2010
ABC
14EE NameEE SupervisorLevel
15JohnHead Honcho0
16MattJohnJohn
17JerryMatt#N/A
18MathiasJohnJohn
19JonesyMatt#N/A
20TrippMathias#N/A
21TaylorJonesy#N/A
22RileyJonesy#N/A
23SarahMeaghan#N/A
24MeaghanJohnJohn
Sheet1
Cell Formulas
RangeFormula
C16=VLOOKUP(B16,$A$15,1,FALSE)
C17=VLOOKUP(B17,$A$15,1,FALSE)
C18=VLOOKUP(B18,$A$15,1,FALSE)
C19=VLOOKUP(B19,$A$15,1,FALSE)
C20=VLOOKUP(B20,$A$15,1,FALSE)
C21=VLOOKUP(B21,$A$15,1,FALSE)
C22=VLOOKUP(B22,$A$15,1,FALSE)
C23=VLOOKUP(B23,$A$15,1,FALSE)
C24=VLOOKUP(B24,$A$15,1,FALSE)


Step 2: Sort the Values By the level field:


Excel 2010
ABC
26EE NameEE SupervisorLevel
27JohnHead Honcho0
28MattJohnJohn
29MathiasJohnJohn
30MeaghanJohnJohn
31JerryMatt#N/A
32JonesyMatt#N/A
33TrippMathias#N/A
34TaylorJonesy#N/A
35RileyJonesy#N/A
36SarahMeaghan#N/A
Sheet1
Cell Formulas
RangeFormula
C28=VLOOKUP(B28,$A$15,1,FALSE)


Step 3: Replace Hits with next sequential level. In this case 1



Excel 2010
ABC
38EE NameEE SupervisorLevel
39JohnHead Honcho0
40MattJohn1
41MathiasJohn1
42MeaghanJohn1
43JerryMatt#N/A
44JonesyMatt#N/A
45TrippMathias#N/A
46TaylorJonesy#N/A
47RileyJonesy#N/A
48SarahMeaghan#N/A
Sheet1
Cell Formulas
RangeFormula
C43=VLOOKUP(B43,$A$15,1,FALSE)
C44=VLOOKUP(B44,$A$15,1,FALSE)
C45=VLOOKUP(B45,$A$15,1,FALSE)
C46=VLOOKUP(B46,$A$15,1,FALSE)
C47=VLOOKUP(B47,$A$15,1,FALSE)
C48=VLOOKUP(B48,$A$15,1,FALSE)


Step 4: Delete #N/A Values


Excel 2010
ABC
50EE NameEE SupervisorLevel
51JohnHead Honcho0
52MattJohn1
53MathiasJohn1
54MeaghanJohn1
55JerryMatt
56JonesyMatt
57TrippMathias
58TaylorJonesy
59RileyJonesy
60SarahMeaghan
Sheet1


Step 5: Repeat Process by changing the table array. This time we look for hits in a table array that contains level 1 employees....


Excel 2010
ABC
62EE NameEE SupervisorLevel
63JohnHead Honcho0
64MattJohn1
65MathiasJohn1
66MeaghanJohn1
67JerryMattMatt
68JonesyMattMatt
69TrippMathiasMathias
70TaylorJonesy#N/A
71RileyJonesy#N/A
72SarahMeaghanMeaghan
Sheet1
Cell Formulas
RangeFormula
C67=VLOOKUP(B67,$A$64:$A$66,1,FALSE)
C68=VLOOKUP(B68,$A$64:$A$66,1,FALSE)
C69=VLOOKUP(B69,$A$64:$A$66,1,FALSE)
C70=VLOOKUP(B70,$A$64:$A$66,1,FALSE)
C71=VLOOKUP(B71,$A$64:$A$66,1,FALSE)
C72=VLOOKUP(B72,$A$64:$A$66,1,FALSE)


Step 2 Again Sort.....


Excel 2010
ABC
75EE NameEE SupervisorLevel
76JohnHead Honcho0
77MattJohn1
78MathiasJohn1
79MeaghanJohn1
80TrippMathiasMathias
81JerryMattMatt
82JonesyMattMatt
83SarahMeaghanMeaghan
84TaylorJonesy#N/A
85RileyJonesy#N/A
Sheet1
Cell Formulas
RangeFormula
C80=VLOOKUP(B80,$A$64:$A$66,1,FALSE)
C81=VLOOKUP(B81,$A$64:$A$66,1,FALSE)
C82=VLOOKUP(B82,$A$64:$A$66,1,FALSE)
C83=VLOOKUP(B83,$A$64:$A$66,1,FALSE)
C84=VLOOKUP(B84,$A$64:$A$66,1,FALSE)
C85=VLOOKUP(B85,$A$64:$A$66,1,FALSE)



Step 3 Again Replace "hits" with next sequential number


Excel 2010
ABC
87EE NameEE SupervisorLevel
88JohnHead Honcho0
89MattJohn1
90MathiasJohn1
91MeaghanJohn1
92TrippMathias2
93JerryMatt2
94JonesyMatt2
95SarahMeaghan2
96TaylorJonesy#N/A
97RileyJonesy#N/A
Sheet1
Cell Formulas
RangeFormula
C96=VLOOKUP(B96,$A$64:$A$66,1,FALSE)
C97=VLOOKUP(B97,$A$64:$A$66,1,FALSE)


Any help getting this process automated would be much appreciated. I have been having trouble figuring out:

How to change the Table Array in the Vlookup Formula within a loop and then also how to signify to stop... This would occur when all Vlookup results are #N/A or all levels are completed. The #N/A scenario can occur if employees report outside of the list I have...The organization is very large so I'm doing this process on thousands of EE's for a large amount of departments. The end goal is to outline by level which I have already been able to successfully code: http://www.mrexcel.com/forum/excel-questions/907185-create-dynamic-outline-multiple-levels-based-outline-hierarchy.html

 
Peter_SSs,

Thanks so much for the thorough explanation! I appreciate you taking the time to explain in greater depth.
 
Upvote 0

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,216,269
Messages
6,129,813
Members
449,538
Latest member
cookie2956

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