Private Sub MonArbre_NodeClick(ByVal Node As MSComctlLib.Node)
If Not Node.parent Is Nothing Then
indicematricule = Sheets("ALGE").Cells(Range(Node.Key).Row, 7)
End If
End Sub
Private Sub UserForm_Initialize()
Dim Pere As String
Dim c As Range
Dim DerLignes As Long
Dim i As Long
DerLignes = Sheets("ALGE").Range("B65536").End(xlDown).Row
'Ce placer sur la première ligne
Set c = Range("BDALGE")(1, 2)
Do
'L'ajouter en tant que Pere
Pere = c.Text
MonArbre.Nodes.Add , , Pere, Pere
' mais aussi en tant que fils (premier numéro de register)
AjouteFils Pere, c
' se positionner à la ligne suivante
Set c = c.Offset(1)
Do
'Si c'est un fils on l'ajoute
if c.text=Pere then
AjouteFils Pere, c
Set c = c.Offset(1)
else
exit do 'sinon sortir de la boucle
end if
Loop While c.Text = Pere 'Boucler tant qu'on est sur le même pere
Loop While Not c.Text = "" 'boucler jusqu'à la première cellule vide
End Sub
Sub AjouteFils(Pere As String, cellule As Range)
Fils = cellule.Offset(, 1)
On Error Resume Next
MonArbre.Nodes.Add Pere, tvwChild, cellule.Offset(, 1).Address, cellule.Offset(, 1).Text
End Sub