Consulting

Results 1 to 6 of 6

Thread: Build parent/child hierarchy

  1. #1
    VBAX Regular
    Joined
    Oct 2012
    Location
    Iasi, Romania
    Posts
    18
    Location

    Build parent/child hierarchy

    Hello,

    I kindly ask for your support because I have to achieve something that seems to be simple but I just can't figure it out how to do it.

    Mainly, I have two columns. The first one contains some parent codes, the second one contains some child codes which can consequently become parent codes for other child codes. And so on.

    Having this in mind, I want to create a hierarchy like the one form the example file (see attachment). The example file was created manually with a minimum number of records but the final database can be way bigger.

    Thank you in advance for your support!
    A.B.

    Also posted here:
    http://www.ozgrid.com/forum/showthread.php?t=201237&p=777920#post777920
    http://www.mrexcel.com/forum/excel-q...ml#post4639220
    Attached Files Attached Files
    Last edited by adygelber; 09-23-2016 at 06:02 AM.

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,729
    Location
    So you're looking for something like this?

    I made it more into a tree so I could see it clearer, and color coded the nodes for traceabiliry

    Capture.JPG
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    VBAX Regular
    Joined
    Oct 2012
    Location
    Iasi, Romania
    Posts
    18
    Location
    Hey Paul,

    If it is easier for you to do it like that, that's fine.
    If it is the same, I preffer it in this form:

    Parent Child
    AB00000 AB00001 AB00000 AB00001 AB00002 AB00005 AB00009 AB00010
    AB00001 AB00002 AB00006
    AB00001 AB00003 AB00007
    AB00001 AB00004 AB00003 AB00011
    AB00002 AB00005 AB00004 AB00008
    AB00002 AB00006
    AB00002 AB00007
    AB00003 AB00011
    AB00004 AB00008
    AB00005 AB00009
    AB00009 AB00010

    Thanks!

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,729
    Location
    Your original had 2-5 in three times

    Do you want to ignore duplicates or expand each?

    Capture.JPG


    Also I assume that a circular reference would be and error?

    For example

    2-4-5-2
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  5. #5
    VBAX Regular
    Joined
    Oct 2012
    Location
    Iasi, Romania
    Posts
    18
    Location
    Please excuse my mistakes from the original example.
    Yes, the duplicates are to be removed and there is also another mistake.

    The correct table should be:

    Parent Child
    AB00000 AB00001 AB00000 AB00001 AB00002 AB00005 AB00009 AB00010
    AB00001 AB00002 AB00006
    AB00001 AB00003 AB00007
    AB00001 AB00004 AB00003 AB00011
    AB00002 AB00005 AB00004 AB00008
    AB00002 AB00006
    AB00002 AB00007
    AB00003 AB00011
    AB00004 AB00008
    AB00005 AB00009
    AB00009 AB00010

    Thank you!

  6. #6
    VBAX Regular
    Joined
    Oct 2012
    Location
    Iasi, Romania
    Posts
    18
    Location
    I received a working answer on MrExcel forum: http://www.mrexcel.com/forum/excel-q...hierarchy.html

    Maybe someone will need the solution.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •