|
Sub myFind2()
Set fso = CreateObject("scripting.filesystemobject")
brr = [o1].CurrentRegion
Application.DisplayAlerts = False
Application.EnableEvents = False
Set fs = fso.getfolder(ThisWorkbook.Path).Files
arr = [a1].Resize(fs.Count + 3, 13)
r = 2
For Each f In fs
If InStr(f.Name, ThisWorkbook.Name) = 0 Then
With Workbooks.Open(f)
b1 = False
b5 = False
For Each sh In .Sheets
If sh.Name = brr(2, 2) Then
b1 = True
Else
If sh.Name = brr(2, 4) Then
b5 = True
End If
End If
Next sh
If b1 Or b5 Then
r = r + 1
arr(r, 1) = f.Name
For j = 3 To UBound(brr)
If b1 = True Then
If Len(brr(j, 2)) > 0 Then arr(r, j - 1) = .Sheets(brr(2, 2)).Range(brr(j, 2))
End If
If b5 = True Then
If Len(brr(j, 4)) > 0 Then arr(r, j + 5) = .Sheets(brr(2, 4)).Range(brr(j, 4))
End If
Next j
End If
.Close False
End With
End If
Next f
ThisWorkbook.Sheets(1).[a1].Resize(r, 13) = arr
Application.EnableEvents = True
Application.DisplayAlerts = True
End Sub
|
评分
-
1
查看全部评分
-
|