M
michael.beckinsale
Hi All
I have a userform with a treeview of an account hierachy. What l am
trying to achieve with the code snippet below is find a node (in this
case with Key = "ADMIN PAY") and then expand all the parent nodes. The
code below works in that it finds the target node and expands that and
the immediate parent but does not go to the next level.
A further complication is that the node to be found can be at any
level between 2 to 7 and all parent nodes above that should be
expanded.
Any help to overcome this problem will be graetly appreciated
Private Sub CommandButton2_Click()
Dim branch As Variant
Dim ToFind As Variant
ToFind = "ADMIN PAY"
With UserForm1.TreeView1
For Each branch In .Nodes
If branch.Key = ToFind Then
branch.Expanded = True
branch.Parent.Expanded = True
End If
Next
End With
End Sub
Regards
Michael
I have a userform with a treeview of an account hierachy. What l am
trying to achieve with the code snippet below is find a node (in this
case with Key = "ADMIN PAY") and then expand all the parent nodes. The
code below works in that it finds the target node and expands that and
the immediate parent but does not go to the next level.
A further complication is that the node to be found can be at any
level between 2 to 7 and all parent nodes above that should be
expanded.
Any help to overcome this problem will be graetly appreciated
Private Sub CommandButton2_Click()
Dim branch As Variant
Dim ToFind As Variant
ToFind = "ADMIN PAY"
With UserForm1.TreeView1
For Each branch In .Nodes
If branch.Key = ToFind Then
branch.Expanded = True
branch.Parent.Expanded = True
End If
Next
End With
End Sub
Regards
Michael