Every time I try the code above or something as simple as
I get an error indicating the 'key is not unique'![]()
TV1.Nodes.Add , , "root", "Root Item"
Every time I try the code above or something as simple as
I get an error indicating the 'key is not unique'![]()
TV1.Nodes.Add , , "root", "Root Item"
Each Nodes key must be unique.
See the attached. There tree contents is on the worksheet.
![]()
Private Sub UserForm_Initialize() Dim rngTreeData As Range Dim lngRow As Long Dim strNodeKey As String Dim strRelativeNode As String Dim strText As String Set rngTreeData = Range("A1").CurrentRegion With rngTreeData For lngRow = 2 To .Rows.Count strNodeKey = .Cells(lngRow, 1) strRelativeNode = .Cells(lngRow, 2) strText = .Cells(lngRow, 3) If strRelativeNode = "" Then ' root TreeView1.Nodes.Add , , strNodeKey, strText Else TreeView1.Nodes.Add strRelativeNode, tvwChild, strNodeKey, strText End If Next End With End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks