OK. One reason it didn't work for you is because you changed the way you put it all together. The way it works out who the AVP is if the person they report to is not found in the employee list. This is the way you set it up in the first place.
That all fell apart when you decided to put the CEO in the list and made them report to themselves!
The second reason, is that although you changed the start row, you didn't change the employee range in this line (this is my fault);
brow = Application.Match(Trim(Range("B" & arow).Value), Range("A19:A9999"), 0)
So I have changed the code somewhat to look for the CEO (the one who reports to himself) and then define an AVP as one who reports to the CEO.
I have also changed it so that if you change the start row again, you only have to change it once.
Also, just so it doesn't ever get caught in a loop, if you have a 'circular reporting' (a reports to b and b reports to a), it will find this for you.
You'll notice in the attachment, I also did a 'sanity check', a couple of columns to check that the person who it picked out as the AVP in each row actually reports to the CEO.
Edited Note: If you change the line I highlighted above to the range you changed the employees to ie.
brow = Application.Match(Trim(Range("B" & arow).Value), Range("A2:A9999"), 0) AND removed MT reporting to MT in the first line (Made both those cells blank), you will get the same AVP list as for the code below.
Just as an aside....this formula =SUMPRODUCT(1/COUNTIF(C3:C96,C3:C96)) will show you how many AVPs you have and it is 7 not 6.
They are, DL, AH, SW, SH, JP, CS and MM.
Bookmarks