|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
代码供参考。。。- Sub ykcbf() '//2024.3.11
- Set Fso = CreateObject("scripting.filesystemobject")
- Set d = CreateObject("Scripting.Dictionary")
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set sh = ThisWorkbook.Sheets("Sheet1")
- With sh
- zrr = .[a1:e8]
- For i = 1 To UBound(zrr)
- s = zrr(i, 1) & "|" & zrr(i, 2) & "|" & zrr(i, 3) & "|" & zrr(i, 5)
- d(s) = ""
- Next
- End With
- ReDim brr(1 To 10000, 1 To 7)
- p = ThisWorkbook.Path & ""
- For Each f In Fso.GetFolder(p).Files
- If f.Name Like "*.xlsb" Then
- fn = Fso.GetBaseName(f)
- Set wb = Workbooks.Open(f, 0)
- With wb.Sheets("Sheet1")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 6)
- wb.Close False
- End With
- For i = 1 To UBound(arr)
- s = arr(i, 1) & "|" & arr(i, 2) & "|" & arr(i, 3) & "|" & arr(i, 5)
- If d.exists(s) Then
- m = m + 1
- For j = 1 To UBound(arr, 2)
- brr(m, j) = arr(i, j)
- Next
- brr(m, 7) = fn
- End If
- Next
- End If
- Next f
- With sh
- .[a12].Resize(10000, 7) = ""
- .[a12].Resize(m, 7) = brr
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|