|
- Public brr(), r&
- Sub lqxs()
- Dim arr, mypath$, myr&
- Dim i&, n&, j&, nm$, drr(1 To 5000, 1 To 7)
- Application.ScreenUpdating = False
- [a2:g5000].ClearContents
- r = 0
- mypath = ThisWorkbook.Path & ""
- Call searfile(mypath, ".xlsx")
- For i = 1 To UBound(brr, 2)
- nm = Split(brr(2, i), "-")(0)
- With GetObject(brr(1, i) & brr(2, i))
- myr = .Sheets(1).Cells(.Sheets(1).Rows.Count, 4).End(xlUp).Row
- arr = .Sheets(1).Range("a31:o" & myr)
- .Close False
- End With
- For j = 1 To UBound(arr)
- n = n + 1
- If j = 1 Then
- drr(n, 1) = nm
- End If
- drr(n, 2) = arr(j, 1): drr(n, 3) = arr(j, 4): drr(n, 4) = arr(j, 6): drr(n, 5) = arr(j, 8): drr(n, 6) = arr(j, 10): drr(n, 7) = arr(j, 14)
- Next
- Next
- Columns(6).NumberFormatLocal = "@"
- [a2].Resize(n, 7) = drr
- Application.ScreenUpdating = True
- MsgBox "ok"
- End Sub
- Sub searfile(fp As String, fkey As String)
- Dim arr1() As String
- Dim i1 As Integer
- Dim i2 As Integer
- Dim fm
- If Right(fp, 1) <> "" Then
- fp = fp & ""
- End If
- If Len(fkey) < 1 Then
- fkey = ".xls"
- End If
- fm = Dir(fp, vbDirectory)
- Do While fm <> ""
- If fm <> "." And fm <> ".." Then
- If (GetAttr(fp & fm) And vbDirectory) = vbDirectory Then
- i1 = i1 + 1
- ReDim Preserve arr1(1 To i1)
- arr1(i1) = fp & fm
- End If
- If Right(fm, Len(fkey)) = fkey Then
- r = r + 1
- ReDim Preserve brr(1 To 2, 0 To r)
- brr(1, r) = fp
- brr(2, r) = fm
- End If
- End If
- fm = Dir
- Loop
- For i2 = 1 To i1
- Call searfile(arr1(i2), fkey)
- Next
- End Sub
复制代码
|
|