|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim nodex As Node
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- With Worksheets("sheet1")
- .AutoFilterMode = False
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:h" & r)
- End With
- With Worksheets("sheet2")
- With .TreeView1
- .Style = 7
- .LineStyle = 1
- .Nodes.Clear
- For i = 1 To UBound(arr)
- If Not d.exists(arr(i, 2)) Then
- Set nodex = .Nodes.Add(, , arr(i, 2), arr(i, 2))
- d(arr(i, 2)) = Empty
- End If
- ss = arr(i, 2)
- For j = 3 To 6
- If Not d.exists(ss & "_" & arr(i, j)) Then
- Set nodex = .Nodes.Add(ss, 4, ss & "_" & arr(i, j), arr(i, j))
- d(ss & "_" & arr(i, j)) = Empty
- End If
- ss = ss & "_" & arr(i, j)
- If j = 6 Then
- If Not IsArray(nodex.Tag) Then
- nodex.Tag = Array(arr(i, 2), arr(i, 3), arr(i, 4), arr(i, 5), arr(i, 6), arr(i, 7), arr(i, 8))
- End If
- End If
- Next
- Next
- End With
- End With
- End Sub
复制代码 |
|