Dear All,
I am trying to get data from Col A of an excel sheet as parents of Treeview. Col B and C are having value of Child. I am able to get the parents name but not able to get the child name fom COl b and C. Please see code below:
Private Sub UserForm_Initialize()
'for excel to treeview
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 and C
For Each c In Sheet3.Range("a1:b" & Range("a" & Rows.Count).End(xlUp).Row)
'Setting parents--THIS PART IS WORKING
Set nParent = TreeView2.Nodes.Add(, , c.Value, c.Value)
'Ensureing no error is there
If Err.Number <> 0 Then
'Error reset and setting parent
Err.Clear
Set nParent = TreeView2.Nodes(c.Value)
End If
'Setting child from col b and c: THIS PART IS NOT WORKING
Set nChild = TreeView2.Nodes.Add(nParent, tvwChild, c.Offset(0, 1).Value, c.Offset(0, 2).Value)
Err.Clear
Next
I am trying to get data from Col A of an excel sheet as parents of Treeview. Col B and C are having value of Child. I am able to get the parents name but not able to get the child name fom COl b and C. Please see code below:
Private Sub UserForm_Initialize()
'for excel to treeview
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 and C
For Each c In Sheet3.Range("a1:b" & Range("a" & Rows.Count).End(xlUp).Row)
'Setting parents--THIS PART IS WORKING
Set nParent = TreeView2.Nodes.Add(, , c.Value, c.Value)
'Ensureing no error is there
If Err.Number <> 0 Then
'Error reset and setting parent
Err.Clear
Set nParent = TreeView2.Nodes(c.Value)
End If
'Setting child from col b and c: THIS PART IS NOT WORKING
Set nChild = TreeView2.Nodes.Add(nParent, tvwChild, c.Offset(0, 1).Value, c.Offset(0, 2).Value)
Err.Clear
Next