|
求大神帮我看看这段代码为什么老是提示堆栈空间不足?帮忙改下,万分感激
父件在B列(共有将近2万条数据),子件在C列。
Public k%
Sub Tree(searchstr As String, depth As Integer)
If [b:b].Find(searchstr, , , 1) Is Nothing Then
Cells(k, depth + 6) = searchstr
k = k + 1
Exit Sub
End If
Dim rng As Range
For Each rng In Range([b3], [b65536].End(xlUp))
If rng = searchstr Then
If [b:b].Find(rng, , , 1).Address = rng.Address Then
Cells(k, depth + 6) = rng
k = k + 1
End If
Call Tree(rng.Offset(0, 1), depth + 1)
End If
Next
End Sub
Sub main()
k = 2
Dim i%
For i = 3 To [b65536].End(xlUp).Row
If [c:c].Find(Cells(i, 2), , , 1) Is Nothing And _
[b:b].Find(Cells(i, 2), , , 1).Row = i Then
Call Tree(Cells(i, 2), 0)
End If
Next
End Sub
|
|