1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| Private Sub TreeView_Populate()
Worksheets(1).Range("C2").Select
Range(Selection, Selection.End(xlDown)).Select
Dim NbTotalCells As Integer
NbTotalCells = Selection.Rows.Count
Dim Group As String
Dim SubGroup As String
Dim Items As String
For i = 2 To NbTotalCells
If Cells(i, 3).Value <> Cells(i - 1, 3).Value Then
Group = Cells(i, 3)
TreeView1.Nodes.Add = Cells(i, 2) & " - " & Group
Else
End If
If Cells(i, 5).Value <> Cells(i - 1, 5) Then
SubGroup = Cells(i, 4) & " - " & Cells(i, 5)
TreeView1.Nodes.Add = SubGroup
Else
End If
If Cells(i, 7).Value <> Cells(i - 1, 7) Then
Items = Cells(i, 6) & " - " & Cells(i, 7)
TreeView1.Nodes.Add = Items
Else
End If
Next i
End Sub |
Partager