|
参与一下。。。
- Sub ykcbf() '//2024.3.25
- Set fso = CreateObject("scripting.filesystemobject")
- Set d = CreateObject("Scripting.Dictionary")
- Application.ScreenUpdating = False
- Set Sh = ThisWorkbook.Sheets("汇总表")
- With Sheets("班级表")
- r = .Cells(Rows.Count, 1).End(3).Row
- For i = 2 To r
- s = .Cells(i, 1)
- d(s) = ""
- Next
- End With
- ReDim brr(1 To 10000, 1 To 10)
- p = ThisWorkbook.Path & ""
- With Application.FileDialog(msoFileDialogFilePicker)
- .InitialFileName = p
- .Title = "请选择对应Excel文件"
- .AllowMultiSelect = False
- .Filters.Clear
- .Filters.Add "Excel文件", "*.xls*"
- If .Show Then f = .SelectedItems(1) Else Exit Sub
- End With
- Set wb = Workbooks.Open(f, 0)
- For Each sht In wb.Sheets
- s = sht.Name
- If d.exists(s) Then
- n = n + 1
- With sht
- r = .Cells(Rows.Count, 3).End(3).Row
- fn = .[a13].Value
- arr = .Range("a15:g" & r)
- If n = 1 Then zrr = .[a14].Resize(1, 7)
- End With
- For i = 1 To UBound(arr)
- If arr(i, 3) <> Empty Then
- m = m + 1
- brr(m, 1) = fn
- For j = 2 To UBound(arr, 2)
- brr(m, j) = arr(i, j)
- Next
- End If
- Next
- End If
- Next
- wb.Close False
- With Sh
- .[a1].Resize(1, UBound(zrr, 2)) = zrr
- .[a2].Resize(m, UBound(arr, 2)) = brr
- .[a1].Resize(1, UBound(zrr, 2)).Interior.Color = 49407
- With .[a1].Resize(m + 1, UBound(arr, 2))
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter '//列居中
- .VerticalAlignment = xlCenter
- End With
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|