|
参与一下,二个表都写了代码。
- Sub ykcbf() '//2024.2.20
- Dim arr, brr(1 To 10000, 1 To 100)
- Set Fso = CreateObject("scripting.filesystemobject")
- Application.ScreenUpdating = False
- Set sh = ThisWorkbook.Sheets("统计表2")
- p = ThisWorkbook.Path & ""
- For Each f In Fso.GetFolder(p).Files
- If 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("汇总表")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .Range("a1:t" & r)
- Wb.Close False
- End With
- For i = 6 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 sh
- .UsedRange.Offset(5).Clear
- With .[a6].Resize(m, UBound(arr, 2))
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- End With
- Application.ScreenUpdating = True
- End Sub
- Sub 数据提取() '//2024.2.20
- Dim arr, brr
- Set d = CreateObject("Scripting.Dictionary")
- Application.ScreenUpdating = False
- arr = ThisWorkbook.Sheets("统计表2").UsedRange
- For i = 6 To UBound(arr)
- s = arr(i, 1)
- d(s) = i
- Next
- With ThisWorkbook.Sheets("统计表1")
- brr = .UsedRange
- For i = 6 To UBound(brr)
- s = brr(i, 1)
- If d.exists(s) Then
- For j = 1 To UBound(brr, 2)
- brr(i, j) = arr(d(s), j)
- Next
- End If
- Next
- .UsedRange = brr
- End With
- Application.ScreenUpdating = True
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|