|
参与一下。。。- Sub ykcbf() '//2024.7.31
- Set fso = CreateObject("scripting.filesystemobject")
- Application.ScreenUpdating = False
- Set sh = ThisWorkbook.Sheets("清单")
- st = CStr(sh.[b2].Value)
- p = ThisWorkbook.Path & "\Test"
- ReDim brr(1 To 10000, 1 To 100)
- For Each f In fso.GetFolder(p).Files
- If LCase$(f.Name) Like "*.xls*" Then
- Set wb = Workbooks.Open(f, 0)
- With wb.Sheets("测试")
- arr = .UsedRange
- wb.Close False
- End With
- For i = 3 To UBound(arr)
- If InStr(CStr(arr(i, 6)), st) Then
- m = m + 1
- For j = 1 To UBound(arr, 2)
- brr(m, j) = arr(i, j)
- Next
- End If
- Next
- End If
- Next f
- With sh
- .[A4].Resize(10000, 100).ClearContents
- .[A4].Resize(m, UBound(arr, 2)) = brr
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|