需要帮助..我已经花了3天但没有结果。我想在treeview中提取数据(sheet1),但无法成功。要求所有专家协助我。
我希望在树视图中显示以下数据(sheet1)。当我点击目录时,它应该显示所有的参与者经理,当我选择特定的经理时,它应该显示所有相应的监督者属于该经理,当我选择特定的主管时,它会显示所有员工属于该主管
如果有人帮助我,我将非常感谢。
Director Senior ManagersSupervisorName EmployeeName
AMP Diwaar Dsameer kap
AMP Diwaar Dsameer Danke
AMP Diwaar Vishaws Bhagan
AMP Rohan Sapla Kumbar
AMP Rohan Sapla Dhavale
AMP Abhijit Maoj Khalsa
AMP Abhijit hiral Rajiwad
AMP Abhijit hiral Shitol
AMP Chandekar Atul Gunjal
AMP Chandekar Atul Gundad
AMP Chandekar Gsamee Patanwala
AMP Dhanesss Ganes Khan
AMP Dhanesss Ganes Keshari
AMP Dhanesss suhai Darwajka
AMP Dhanesss suhai Nirmale
答案 0 :(得分:0)
如果我们尝试添加已经存在的节点,Nodes.Add
会抛出错误,我们可以这样简单地执行此操作。
Private Sub UserForm_Initialize()
Set rTWData = ThisWorkbook.Worksheets("Sheet1").Range("A2:D16")
With TreeView1
Set oNode = .Nodes.Add(, , "root", "+")
oNode.Expanded = True
On Error Resume Next
For Each oRow In rTWData.Rows
.Nodes.Add "root", tvwChild, oRow.Cells(1, 1).Value, oRow.Cells(1, 1).Value
.Nodes.Add oRow.Cells(1, 1).Value, tvwChild, oRow.Cells(1, 2).Value, oRow.Cells(1, 2).Value
.Nodes.Add oRow.Cells(1, 2).Value, tvwChild, oRow.Cells(1, 3).Value, oRow.Cells(1, 3).Value
.Nodes.Add oRow.Cells(1, 3).Value, tvwChild, oRow.Cells(1, 4).Value, oRow.Cells(1, 4).Value
Next
On Error GoTo 0
End With
End Sub
On Error Resume Next
只会超越我们尝试添加为重复的所有节点。