Re : Treeview noeud enfant vba
bonjour Nina
si j'ai le temps essayer avec 3 colonnes fils, pere,ce qui s'affiche
c'est peut être dans la structure,je connais pas trop treeview
si ce code t'intéresse
Private Sub userform_initialize()
10 Application.ScreenUpdating = False
Me.ListBox2.ColumnCount = 3
Me.ListBox2.ColumnWidths = "60;30;30"'tu mets 0 pour cacher
With ThisWorkbook.Sheets("programmes activités")
20 For i = 2 To .Range("A65536").End(xlUp).Row
30 If Left(.Range("B" & i), 6) = "projet" Then
Me.ListBox2.AddItem .Range("B" & i).Value
j = j + 1
Select Case j
Case 1
Me.ListBox2.List(0, 1) = i 'debut
Case 2
Me.ListBox2.List(1, 1) = i
Me.ListBox2.List(0, 2) = i - 1 'fin
Case 3
Me.ListBox2.List(2, 1) = i
Me.ListBox2.List(1, 2) = i - 1 'fin
Case 4
Me.ListBox2.List(3, 1) = i
Me.ListBox2.List(2, 2) = i - 1 'fin
Case 5
Me.ListBox2.List(4, 1) = i
Me.ListBox2.List(3, 2) = i - 1 'fin
Case 6
Me.ListBox2.List(5, 1) = i
Me.ListBox2.List(4, 2) = i - 1 'fin
Me.ListBox2.List(5, 2) = Sheets("programmes activités").Range("A65536").End(xlUp).Row
End Select
End If
210 Next i
End With
1390 'ThisWorkbook.Sheets("programmes activités").Visible = False
1400 Application.ScreenUpdating = True
End Sub
Private Sub listbox2_Click()
10 Me.monarbre.Nodes.Clear
20 Sheets("arbre").Cells.Clear
30 ActiveWorkbook.Names("BDprogramme").Delete
40 Titre = Me.ListBox2.Value
ld = Me.ListBox2.List(Me.ListBox2.ListIndex, 1): lf = Me.ListBox2.List(Me.ListBox2.ListIndex, 2)
Sheets("programmes activités").Range("A1:B2").Copy Destination:=Sheets("arbre").Range("A1")
Sheets("programmes activités").Range("A" & ld & ":B" & lf).Copy Destination:=Sheets("arbre").Range("A3")
With ThisWorkbook.Sheets("arbre")
320 k = .Range("A65536").End(xlUp).Row
340 .Range("A2:B" & k).Name = "BDprogramme"
End With
pere = "0"
nomPere = Application.VLookup(pere, [BDprogramme], 2, False)
'Application.VLookup(pere, [BDprogramme], 2, False)
370 Set tw = Me.monarbre
n = [BDprogramme].Rows.Count
390 base = [BDprogramme]
'tw.Nodes.Add(noeud_père,twchild,création_noeud_courant,libellé_noeud)
tw.Nodes.Add(, , "NoeudMat" & pere, nomPere).Expanded = True ' Racine arbre
' For i = 2 To n
'
' Next
vpersonnes pere
420 For Each TVNode In tw.Nodes
430 TVNode.ForeColor = vbBlack
440 Next
End Sub