none
vba not loading all data in treeview RRS feed

  • Question

  • With the help of below coding, I am able to reflect the data in tree view. The only problem I am facing is that it shows only first item on child node and does not load the remaining items. Please assist me. It is not loading all the data.


    Dim rTWData As Range
    Dim oRow As Variant
    Dim onode As Variant
    Dim lastrow As Integer

    Dim myFileNameDir2 As String
    Dim ws12 As Worksheet
    Dim i2 As Integer
    Dim lastrow2 As Integer
    Dim filecheck As Variant


    myFileNameDir2 = Sheet1.Range("V5").Value
    Workbooks.Open Filename:=myFileNameDir2, UpdateLinks:=0
    Set ws12 = Worksheets(1)

    lastrow = ws12.Range("A" & Rows.Count).End(xlUp).Row - 1

    MsgBox lastrow
    Set rTWData = ws12.Range("A2:L" & lastrow)


    With TreeView1
    Set onode = .Nodes.Add(, , "root", "+")
    onode.Expanded = True

    For Each oRow In rTWData.Rows
    .Nodes.Add "root", tvwChild, oRow.Cells(1, 2).Value, oRow.Cells(1, 2).Value
    .Nodes.Add oRow.Cells(1, 1).Value, tvwChild, oRow.Cells(1, 3).Value, oRow.Cells(1, 3).Value
    '.Nodes.Add oRow.Cells(1, 2).Value, tvwChild, oRow.Cells(1, 4).Value, oRow.Cells(1, 4).Value
    '.Nodes.Add oRow.Cells(1, 3).Value, tvwChild, oRow.Cells(1, 5).Value, oRow.Cells(1, 5).Value
    Next
    End With




    • Edited by GShaikh Friday, January 6, 2017 3:48 PM
    Friday, January 6, 2017 3:21 PM