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 36 37 38 39 40 41 42 43
| Private Sub UserForm_Initialize()
Dim NumCol As Integer, j As Integer
Dim NumLig As Integer, k As Integer
Dim Cell As Range
'Boucle sur les éléments de la structure pour remplir le TreeView
For Each Cell In Sheets("test").Range("A1:A" & Sheets("test").Range("N65533").End(xlUp).Row)
NumCol = Cell.End(xlToRight).Column
NumLig = Cell.Row
'Les informations de la colonne B correspondent à un noeud principal
If NumCol = 2 Then
TreeView1.Nodes.Add , , "maCle" & NumLig & NumCol, Sheets("test").Cells(NumLig, NumCol)
k = Sheets("test").Cells(NumLig, NumCol).Offset(0, -1).End(xlUp).Row
j = Sheets("test").Cells(NumLig, NumCol).Offset(0, -1).Column
'S'il s'agit d'un membre de l'équipe:
'(Dans ce cas la colonne N contient la lettre "x")
If Sheets("test").Cells(NumLig, 14) = "x" Then
TreeView1.Nodes.Add "maCle" & k & j, tvwChild, "maCle" & NumLig & NumCol, Sheets("test").Cells(NumLig, NumCol)
Else
'S'il s'agit d'une sous famille:
TreeView1.Nodes.Add "maCle" & k & j, tvwChild, "maCle" & NumLig & NumCol, Sheets("test").Cells(NumLig, NumCol)
End If
End If
Next Cell |
Partager