Hello. I've created a treeview using the below code, which gets the parents and childs from a sheet, but I'm struggling to get my head around updating a label depending on what node is selected. If a parent is selected then I need to update the label with the relevant cell info probably using an offset and the same for a child. I need to reference the selected node with that of the range on the sheet, so column A8:A for parent and B8:B for child. Any examples or pointers would be greatly appreciated as I'm currently banging my head against the wall. Thanks
Private Sub DirTV()
Dim c As Range
Dim nParent As Node
Dim nChild As Node
'ON error next
On Error Resume Next
'Parents are stored in Col A and child are stored in col B
For Each c In Worksheets("Directory").Range("a8:a" & Range("a" & Rows.Count).End(xlUp).Row)
'Setting parents
Set nParent = DirectoryTree.Nodes.Add(, "Parent" + c.Value, c.Value, c.Value)
'Ensureing no error is there
If Err.Number <> 0 Then
'Error reset and setting parent
Err.Clear
Set nParent = DirectoryTree.Nodes(c.Value)
End If
'Setting child from col b
Set nChild = DirectoryTree.Nodes.Add(nParent, tvwChild, c.Value + c.Offset(0, 1).Value, c.Offset(0, 1).Value)
Next
End Sub
Private Sub DirTV()
Dim c As Range
Dim nParent As Node
Dim nChild As Node
'ON error next
On Error Resume Next
'Parents are stored in Col A and child are stored in col B
For Each c In Worksheets("Directory").Range("a8:a" & Range("a" & Rows.Count).End(xlUp).Row)
'Setting parents
Set nParent = DirectoryTree.Nodes.Add(, "Parent" + c.Value, c.Value, c.Value)
'Ensureing no error is there
If Err.Number <> 0 Then
'Error reset and setting parent
Err.Clear
Set nParent = DirectoryTree.Nodes(c.Value)
End If
'Setting child from col b
Set nChild = DirectoryTree.Nodes.Add(nParent, tvwChild, c.Value + c.Offset(0, 1).Value, c.Offset(0, 1).Value)
Next
End Sub