|
- Sub 查询() 'bajifeng
- Dim br(), ar, i%, j%, n&, fn$, ipath$
- w = [b1]
- ipath = ThisWorkbook.Path & ""
- fn = Dir(ipath & "*.xls?")
- Application.ScreenUpdating = False
- Do
- If Not fn Like ThisWorkbook.Name Then
- With Workbooks.Open(ipath & fn)
- For Each sht In .Worksheets
- ar = sht.Range("a3:i" & [a65536].End(3).Row)
- For i = 1 To UBound(ar)
- If InStr(ar(i, 2), w) > 0 Then
- n = n + 1
- ReDim Preserve br(1 To 10, 1 To n)
- br(1, n) = sht.Name
- For j = 1 To 9
- br(1 + j, n) = ar(i, j)
- Next
- End If
- Next
- Next
- .Close False
- End With
- End If
- fn = Dir
- Loop While fn <> ""
- [a3:j65536] = ""
- [a3].Resize(n, 10) = Application.Transpose(br)
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|