+ Reply to Thread
Results 1 to 5 of 5

parent-child relationship in a tree diagram using VBA

  1. #1
    Registered User
    Join Date
    03-20-2020
    Location
    Singapore
    MS-Off Ver
    2016
    Posts
    4

    parent-child relationship in a tree diagram using VBA

    I am building a organisational structure for a company. However, my current VBA script does not have a parent-child relationship eg(Trainer under Team Leader). How can i create the relationship in macro and display it in the organisational structure? In the picture below, Jodan and Sky are supposed to be under Jane. I have not created a parent column yet but i have no idea how to go about writing the code to link the child(Jodan and Sky) to the parent(Jane) so that they appear below Jane instead of below Kite. Thank you for your help!
    This is my VBA code:
    Please Login or Register  to view this content.

    structure.PNG
    Attached Files Attached Files
    Last edited by ruiru; 03-20-2020 at 11:55 AM.

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: parent-child relationship in a tree diagram using VBA

    Hello ruiru & Welcome to the Forum,

    Give this a try. On Sheet2, you need to have the org in the hierarchal structure which may mean you need to adjust Sheet1. Anyway, on Sheet2 in column C, this is where you are going to put the reports to.
    Attached Files Attached Files
    Last edited by jeffreybrown; 03-21-2020 at 08:59 AM.
    HTH
    Regards, Jeff

  3. #3
    Registered User
    Join Date
    03-20-2020
    Location
    Singapore
    MS-Off Ver
    2016
    Posts
    4

    Re: parent-child relationship in a tree diagram using VBA

    thank you jeffreybrown, it helped me a lot! one additional question i want to ask is, how do i color the node if let's say the designation is a director?

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: parent-child relationship in a tree diagram using VBA

    Updated post #2

    In column B, apply the colors you want.

  5. #5
    Registered User
    Join Date
    09-08-2023
    Location
    Germany
    MS-Off Ver
    13
    Posts
    1

    Re: parent-child relationship in a tree diagram using VBA

    Hi, do you know how to add label for connectors (connection between parent ID and ID) as well as add "+" or "-" to expand and collapse data on the tree? Thank you a lot!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Parent Child relationship issue: Get parent ID for child
    By masterl1983 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 08-28-2018, 07:35 AM
  2. [SOLVED] Sorting with Parent and Child
    By dominict in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-04-2013, 06:56 AM
  3. [SOLVED] Parent child relationships(working out parent item) for each item
    By grphillips in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 03-21-2013, 05:58 AM
  4. Parent Child Relationship
    By Automation Guru in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-02-2013, 04:48 AM
  5. Vba code for Parent child
    By ken4ward in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-06-2012, 06:04 AM
  6. Replies: 4
    Last Post: 08-30-2009, 03:43 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1