|
Sub 查询()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Set d = CreateObject("Scripting.Dictionary")
P = ThisWorkbook.Path & "\"
d.Add P, ""
I = 0
Do While I < d.Count
brr = d.keys
F = Dir(brr(I), vbDirectory)
Do While F <> ""
If F <> "." And F <> ".." Then
If (GetAttr(brr(I) & F) And vbDirectory) = vbDirectory Then d.Add (brr(I) & F & "\"), ""
End If
F = Dir
Loop
I = I + 1
Loop
For Each k In d.keys
F = Dir(k & "*.XLSX")
Do While F <> ""
If F <> ThisWorkbook.Name Then
Set WB = Workbooks.Open(P & F)
For Each sh In WB.Sheets
Set Rng = sh.Cells.Find("*\*")
If Not Rng Is Nothing Then
s = Rng.Address
Do
n = n + 1
With ThisWorkbook.Sheets(2)
.Cells(n, 1) = k
.Cells(n, 2) = F
.Cells(n, 3) = sh.Name
.Cells(n, 4) = s
End With
Set Rng = sh.Cells.FindNext(Rng)
Loop While s <> Rng.Address
End If
Next
WB.Close
End If
F = Dir
Loop
Next
Set d = Nothing
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
|
|