|
参与一下。。。
- Sub ykcbf() '//2024.7.30
- Set fso = CreateObject("scripting.filesystemobject")
- Application.ScreenUpdating = False
- Set sh = ThisWorkbook.Sheets("汇总")
- sh.[a3].Resize(1000, 100).ClearContents
- p = ThisWorkbook.Path & ""
- ReDim brr(1 To 10000, 1 To 100)
- For Each f In fso.GetFolder(p).Files
- If LCase$(f.Name) Like "*.xls*" Then
- If InStr(f.Name, ThisWorkbook.Name) = 0 Then
- fn = fso.GetBaseName(f)
- Set wb = Workbooks.Open(f, 0)
- n = n + 1
- With wb.Sheets(1)
- arr = .UsedRange
- If n = 1 Then
- r1 = .Cells(Rows.Count, 2).End(3).Row
- .Rows(4 & ":" & r1).Copy sh.[a3]
- Else
- For i = 6 To UBound(arr)
- If arr(i, 2) <> Empty Then
- m = m + 1
- For j = 1 To UBound(arr, 2)
- brr(m, j) = arr(i, j)
- Next
- End If
- Next
- End If
- End With
- wb.Close 0
- End If
- End If
- Next f
- With sh
- .Cells(r1, 1).Resize(m, UBound(arr, 2)) = brr
- r = .Cells(Rows.Count, 1).End(3).Row
- .Rows("6:6").Copy
- .Rows("7:" & r).PasteSpecial Paste:=xlPasteFormats
- Application.CutCopyMode = False
- .[a5].Resize(r - 4, UBound(arr, 2)).Sort .[a5], 1
- .[i2].Select
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|