Enable parent nodes in treeview if child is checked

Gargoolgala

New Member
Joined
Sep 1, 2016
Messages
6
Hi - I have a treeview that can have multiple parent nodes with children beneath. I need to be able to have the parent or parents parent and so on checked if a child anywhere down the tree is checked.

parent
- child1
parent2
- child1
- child2
- subchild1
- subchild2

if any of the children are checked I need the parent checked - so if child1, child2 or subchild1 is checked then I need parent2 and child2 subchild1 to all be checked. If I uncheck subchild1 and no other subchildren are checked then I want child2 to be unchecked and parent 2 to also be unchecked but only if no other children of parent2 are checked. So if I uncheck subchild1 but child1 is checked then I need parent2 to stay checked but child2 to be unchecked.

I think I need to do some recursive magic but cannot get my head around it. Most posts I have found seem to focus on checking from the top down but I think I need to look from the bottom up - sooo confused.

Any assistance is appreciated.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,224,524
Messages
6,179,308
Members
452,904
Latest member
CodeMasterX

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