|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
香川合并法- Sub ykcbf() '//2024.6.18 香川合并法
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Dim tm: tm = Timer
- Dim brr, arr, x
- p = ThisWorkbook.Path
- Set sh = ThisWorkbook.Sheets("Sheet1")
- brr = Split(CreateObject("Wscript.Shell").exec("cmd /c dir /a-d /b /s " & Chr(34) & p & Chr(34)).StdOut.ReadAll, vbCrLf)
- brr = Filter(brr, ThisWorkbook.Name, 0)
- sh.UsedRange.ClearContents
- For x = 0 To UBound(brr)
- m = m + 1
- If Len(brr(x)) Then
- Set wb = Workbooks.Open(brr(x), 0)
- With wb.Sheets("Sheet1")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = [a1].Resize(r, 5)
- End With
- wb.Close 0
- r = IIf(m = 1, 1, sh.Cells(sh.Rows.Count, "a").End(xlUp).Offset(1).Row)
- sh.Cells(r, 1).Resize(UBound(arr), UBound(arr, 2)) = arr
- End If
- Next
- Application.ScreenUpdating = True
- MsgBox "运行完毕,共用时: " & Format(Timer - tm, "0.000秒"), , "提示"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|