AW: TreeView Sortierung
09.05.2019 09:24:25
Nepumuk
Hallo Sigi,
würde ich so machen:
Private Sub CommandButton2_Click()
Const cintLevel As Integer = 2
Dim objDictionary As Object
Dim objNode(1 To cintLevel) As Node
Dim lngRow As Long
Dim intCounter As Integer
Dim intLevel As Integer
Dim strKey As String
TreeView2.Nodes.Clear
Set objDictionary = CreateObject(Class:="Scripting.Dictionary")
With Worksheets("Tabelle1")
For lngRow = 1 To .Cells(.Rows.Count, 2).End(xlUp).Row
If .Cells(lngRow, 2).Value = "" Then Exit For
For intLevel = 2 To cintLevel
If .Cells(lngRow, intLevel).Value = "" Then Exit For
strKey = .Cells(lngRow, intLevel).Value
If Not objDictionary.Exists(Key:=strKey) Then
Call objDictionary.Add(Key:=strKey, Item:=vbNullString)
If objNode(2) Is Nothing Then
Set objNode(2) = TreeView2.Nodes.Add(, , , strKey)
Else
Set objNode(2) = TreeView2.Nodes.Add(objNode(2).Index, tvwNext, , strKey)
End If
End If
Next intLevel
Next lngRow
End With
Set objDictionary = Nothing
End Sub
Gruß
Nepumuk