|
不太明白楼主要什么样式的列表,做了个,如附图,如果是这样的形式,那代码如下:
Private Sub UserForm_Initialize()
On Error Resume Next
With Sheets("sheet1")
Const rule = "rule"
Set Rng = .Range("f4:f" & .[a65536].End(xlUp).Row)
With TreeView1
.Style = tvwTreelinesPlusMinusPictureText
.LineStyle = tvwRootLines
.CheckBoxes = False
.Nodes.Clear
.Nodes.Add , , rule, rule
For Each xcell In Rng
i = i + 1
.Nodes.Add rule, tvwChild, xcell(1, -2).Value, xcell(1, -2).Value
.Nodes.Add xcell(1, -2).Value, tvwChild, xcell(1, -1).Value, xcell(1, -1).Value
.Nodes.Add xcell(1, -1).Value, tvwChild, xcell(1, 0).Value, xcell(1, 0).Value
.Nodes.Add xcell(1, 0).Value, tvwChild, xcell.Value & i, xcell.Value
Next
End With
End With
End Sub |
|