Macro to build company trees

Texas Longhorn

Active Member
Joined
Sep 30, 2003
Messages
493
Please forgive me if this makes no sense. Here goes:

I am working on a project to establish territories for our sales reps. Each sales rep gets a list of 50 "named" accounts.

The process we've been through thus far: My goal was to identify the top 1,500 companies in the U.S. based on various criteria. I pulled down about 40,000 records from Dun & Bradstreet, and applied various criteria to end up with a list of the top 1,500.

Now, this 1,500 consists of large companies, about 90% of which are what Dun & Bradstreet calls "Ultimate Parents" (parent companies with many subsidiaries). The other 10% are companies that are subsidiaries of other companies; however, for whatever reason, the parent company did not meet the criteria to make the list of 1,500. This 10% are not "Ultimate Parents", but they are all parents (so if a company was 6 layers deep on an org chart, they might be on level two or three).

The next step was to take the list of 1,500 companies and send their DUNS numbers (Dun & Bradstreet's unique number) to Dun & Bradstreet so they could give me a list of all subsidiaries for the companies I chose.

This is where the wheels have fallen off a bit. For some reason, D&B is claiming to be incapable of putting the data in the format I need which is as follows: In the first column, I need the numbers I requested; in the second column I need any company that rolls up to that number, no matter where it is in the org chart (e.g. If the DUNS number I requested represents a company on the 3rd level of an organization, I want to see it's number, any level 4 company that rolls up to it, and level 5 company that rolls up to a level 4 company that rolls up to it, etc.) The trick here is that I only need companies in the specific lineage of the number I specify.

Hopefully my examples will clarify this (I've had to post in separate messges due to size).
 
In the below data, explain how we get all these to the stated DUNS given -- not sure I'm exactly clear on the methodology...
DNB-1.xls
ABCDEFG
2497311-118-2197WppGroupUSInvestments,Inc217187160WPPGroupPLC111182197WppGroupUSInvestments,Inc
2497400-699-251500-699-2515Young&RubicamInc111182197WppGroupUSInvestments,Inc111182197WppGroupUSInvestments,Inc
2497500-699-251500-699-2515Young&RubicamInc111182197WppGroupUSInvestments,Inc111182197WppGroupUSInvestments,Inc
2497613-249-9901Mosaica111182197WppGroupUSInvestments,Inc111182197WppGroupUSInvestments,Inc
2497760-348-870160-348-8701WppGroupUsa,Inc111182197WppGroupUSInvestments,Inc111182197WppGroupUSInvestments,Inc
2497860-348-870160-348-8701WppGroupUsa,Inc111182197WppGroupUSInvestments,Inc111182197WppGroupUSInvestments,Inc
2497901-681-8023JWTStatInc6991160JWalterThompsonCompany111182197WppGroupUSInvestments,Inc
From DNB
 
Upvote 0

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
I was envisioning a code that would loop through the DUNS numbers on the List to DNB tab. On a third tab (in DNB.xls), two columns would be established: one corresponding to the numbers from List to DNB!, and the second for any DUNS numbers that roll up to that number.

So, the desired output for the example you posted would be:
Book1
ABCD
1RollupDUNSSubsidiaryDUNS
200-699-251500-699-2515
300-699-251504-815-9297
400-699-251507-135-7425
500-699-251509-051-0298
600-699-251510-623-0659
700-699-251511-694-7420
800-699-251513-387-4409
900-699-251579-309-9367
1000-699-251579-986-0499
1100-699-251596-690-7503
1260-348-870160-348-8701
1360-348-870100-592-6618
1460-348-870101-029-8628
1560-348-870104-123-7058
1660-348-870106-496-0495
1760-348-870106-582-0482
1860-348-870107-516-2099
1960-348-870109-799-1699
2060-348-870109-984-7857
2160-348-870117-328-7780
2260-348-870117-862-4524
2360-348-870136-144-8749
2460-348-870161-437-4106
2560-348-870178-390-0731
2660-348-870180-348-0946
2760-348-870187-499-0500
2860-348-870196-804-4180
2960-348-870108-300-0547
3060-348-870111-353-9725
3160-348-870109-108-6066
3260-348-870119-247-5275
3360-348-870193-831-0711
3460-348-870194-195-6898
3560-348-870196-962-2687
3660-348-870104-006-2291
Sheet3


The whole challenge (for me) is to have the code say: Find this DUNS (e.g. 60-348-8701) every time it is listed as a parent in column D. Now, choose all of those records. Next, loop through each of those records and see if their DUNS numbers from column B ever occur as parents in column D. If they do, grab those records. Next, loop those records, etc...until it's done.

Please let me know if this helps...I have a lot of difficulty explaining the issue exactly.

Thanks again for all the help,

Bill
 
Upvote 0
I have tried this for another project of mine, and ended up with the following routines.

Basically it creates a 'tree' based on the input heirarchy.

It sounds like I can adapt it easily enough though.

Caould you send me the data, and I will look into it.
 
Upvote 0
I have done something very similar just recently.

If you send me the file I should be able to adjust what I have done easily enough.
 
Upvote 0

Forum statistics

Threads
1,214,822
Messages
6,121,772
Members
449,049
Latest member
greyangel23

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