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
| Dim AB As MSComctlLib.TreeView
Private Sub Arbre1_BeforeLabelEdit(Cancel As Integer)
If Left(Node.Key, 8) = "NoeudMat" Then
Me.Produits = Application.VLookup(Val(Mid(Node.Key, 9)), [Produits], 3, False)
End Sub
Private Sub UserForm1_Initialize()
Dim Base, n
Dim Départ(1 To 15)
Set AB = Me.Arbre1
[Produits].Sort key1:=[Produits].Cells(1, 2)
n = [Produits].Rows.Count
Base = [Produits]
AB.Nodes.Add(, , "NoeudInit", "Début").Expanded = True
For i = 1 To n
If IsError(Application.Match(Base(i, 3), Départ, 0)) Then
AB.Nodes.Add("NoeudInit", tvwChild, "NoeudDep" & Base(i, 3), Base(i, 3)).Expanded = True
AB = AB + 1
Départ(AB) = Base(i, 3)
End If
Next i
For i = 1 To n
AB.Nodes.Add("NoeudDep" & Base(i, 3), tvwChild, "NoeudMat" & Base(i, 1), Base(i, 2)).Expanded = True
Next i
End Sub |
Partager