|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
参与一下。。。
- Sub ykcbf() '//2024.12.3 合并
- Application.ScreenUpdating = False
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set d = CreateObject("Scripting.Dictionary")
- p = ThisWorkbook.Path & ""
- Set ws = ThisWorkbook
- With ws.Sheets("目录")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 3)
- For i = 1 To UBound(arr)
- If .Cells(i, 3).Value = True Then d(arr(i, 2)) = ""
- Next
- End With
- ReDim brr(1 To 10000, 1 To 100)
- For Each f In fso.GetFolder(p).Files
- If LCase$(f.Name) Like "*.xls*" Then
- fn = fso.GetBaseName(f)
- If d.exists(fn) Then
- n = n + 1
- Set wb = Workbooks.Open(f, 0)
- With wb.Sheets(1)
- arr = .UsedRange
- wb.Close False
- End With
- For i = IIf(n = 1, 1, 2) To UBound(arr)
- m = m + 1
- For j = 1 To UBound(arr, 2)
- brr(m, j) = arr(i, j)
- Next
- Next
- End If
- End If
- Next f
- With ws.Sheets("合并")
- .UsedRange.Clear
- .[a1].Resize(m, 3) = brr
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|