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).
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
My desired output:
Book4
ABCD
1RollupDUNSSubsidiaryDUNS
213076021307602
3130760215261951
4130760290099672
5130760290358029
61307602104087051
71307602126980861
81307602927001636
9130760290131251
1013076021023472
1113076022111896
1213076029125527
1330125493012549
14301254910112154
15301254929692568
16301254954986757
17301254956637879
18301254986031028
193012549190450908
203012549783734841
213012549794306423
223012549928445790
233012549957381288
2430125498425084
253012549105560747
263012549139376966
Sheet3
 
Upvote 0
And what D&B gave me as output:
Book4
ABCDEFG
1SubsidiaryD-U-N-SNumbersBUSINESSNAMEPARENTD-U-N-SNUMBERPARENT/HQNAMEDOMESTICULTIMATED-U-N-SNUMBERDOMESTICULTIMATEBUSINESSNAMEHIERARCHYCODE
21307602AbbottLaboratoriesAbbottLaboratories1307602AbbottLaboratories1
315261951ZoneperfectNutritionCoInc1307602AbbottLaboratories1307602AbbottLaboratories2
490358029AbbottHealthProductsInc1307602AbbottLaboratories1307602AbbottLaboratories2
5104087051OximetrixInc1307602AbbottLaboratories1307602AbbottLaboratories2
6126980861AbbottInternationalLtd1307602AbbottLaboratories1307602AbbottLaboratories2
7927001636AbbottBioresearchCenter1307602AbbottLaboratories1307602AbbottLaboratories2
890131251AbbottChemicals,Inc.90358029AbbottHealthProductsInc1307602AbbottLaboratories3
91023472TycoInternational(us)Inc875632788TycoInternationalLtd.1023472TycoInternational(us)Inc2
102111896GraphicControlsCorporation87602731TycoInternational(pa)Inc87602731TycoInternational(pa)Inc3
119125527TycoElectronics/Raychem87602731TycoInternational(pa)Inc87602731TycoInternational(pa)Inc3
123012549TycoElectronicsCorporation1023472TycoInternational(us)Inc1023472TycoInternational(us)Inc3
1344680650UnitedStatesSurgicalCorporation1023472TycoInternational(us)Inc1023472TycoInternational(us)Inc3
1453988150EloTouchsystemsInc9125527TycoElectronics/Raychem87602731TycoInternational(pa)Inc4
1583152090Tronomed,Inc2111896GraphicControlsCorporation87602731TycoInternational(pa)Inc4
16867626921RaychemInternationalManufacturingCorp9125527TycoElectronics/Raychem87602731TycoInternational(pa)Inc4
1710112154M/A-Com,Inc.3012549TycoElectronicsCorporation1023472TycoInternational(us)Inc4
1829692568FiskCorporation3012549TycoElectronicsCorporation1023472TycoInternational(us)Inc4
1954986757TycoElectronicsInc3012549TycoElectronicsCorporation1023472TycoInternational(us)Inc4
2056637879Corcom,Inc.3012549TycoElectronicsCorporation1023472TycoInternational(us)Inc4
21957381288PinaclCommunicationInc3012549TycoElectronicsCorporation1023472TycoInternational(us)Inc4
2291133710USSCPuertoRicoInc44680650UnitedStatesSurgicalCorporation1023472TycoInternational(us)Inc4
23152103172USSSportsMedicine44680650UnitedStatesSurgicalCorporation1023472TycoInternational(us)Inc4
24798190419NationalIntegrationServices,Inc53988150EloTouchsystemsInc87602731TycoInternational(pa)Inc5
258425084FiskElectricCompany29692568FiskCorporation1023472TycoInternational(us)Inc5
2654652201NellcorPuritanBennettIncorporated47021092MallinckrodtInc1023472TycoInternational(us)Inc5
27105560747OnesourceBuildingTechnologies,Inc29692568FiskCorporation1023472TycoInternational(us)Inc5
28139376966Tech-CeramCorp10112154M/A-Com,Inc.1023472TycoInternational(us)Inc5
29115521101NellcorPuritanBennettInternationalCorporation54652201NellcorPuritanBennettIncorporated1023472TycoInternational(us)Inc6
30801049438NellcorInc54652201NellcorPuritanBennettIncorporated1023472TycoInternational(us)Inc6
Sheet1


Sorry - I had to remove a few rows for the html writer to accept this.

What I'm in need of is some code that would loop through the output D&B sent me, and, based on the numbers I supplied (in the second example), produce my desired output.

I know this is confusing, so please ask any questions you need.

Many thanks for any help you can give with this.

Thanks,

Bill
 
Upvote 0
Haven't time now; if you've gotten no solution by tomorrow, i'll try to look back in to it again. Might need the file...
 
Upvote 0

Forum statistics

Threads
1,214,561
Messages
6,120,225
Members
448,951
Latest member
jennlynn

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