|
参与一下。。。
- Sub ykcbf() '//2024.8.22
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set sh = ThisWorkbook.Sheets("Sheet1")
- With Application.FileDialog(msoFileDialogFolderPicker)
- .Title = "请选择文件夹"
- .InitialFileName = ThisWorkbook.Path & ""
- If .Show = -1 Then
- p = .SelectedItems(1) & ""
- End If
- End With
- ReDim brr(1 To 10000, 1 To 3)
- 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)
- With wb.Sheets(1)
- arr = .UsedRange
- wb.Close False
- End With
- For i = 2 To UBound(arr)
- If arr(i, 1) <> Empty Then
- m = m + 1
- brr(m, 1) = arr(i, 2)
- brr(m, 2) = arr(i, 6)
- brr(m, 3) = arr(i, 3)
- End If
- Next
- End If
- End If
- Next f
- ReDim zrr(1 To 10000, 1 To 3)
- With sh
- r = .Cells(Rows.Count, "g").End(3).Row
- .Columns(8).NumberFormatLocal = "@"
- .Cells(r + 1, "g").Resize(m, 3) = brr
- arr = .[g2].Resize(r + m, 3)
- .[a2:c10000] = ""
- For i = 1 To UBound(arr)
- s = arr(i, 1)
- If Not d.exists(s) Then
- n = n + 1
- d(s) = n
- zrr(n, 1) = arr(i, 1)
- zrr(n, 2) = arr(i, 2)
- zrr(n, 3) = arr(i, 3)
- Else
- r = d(s)
- zrr(r, 3) = zrr(r, 3) + arr(i, 3)
- End If
- Next
- .Columns(2).NumberFormatLocal = "@"
- .[a2].Resize(n, 3) = zrr
- End With
- Application.ScreenUpdating = True
- End Sub
复制代码
|
评分
-
2
查看全部评分
-
|