|
楼主 |
发表于 2020-3-14 16:18
|
显示全部楼层
参考网上资源,改写了一下,比自己想象中要麻烦些,有好的改进方法吗?
Sub cx()
Dim MyPath$, MyName$, wb As Workbook, sh As Worksheet, sh0 As Worksheet, Arr, i, j, k
MyPath = ThisWorkbook.Path & "\"
MyName = Dir(MyPath & "*.xlsm")
Application.ScreenUpdating = False
On Error Resume Next
With ThisWorkbook.Sheets
Do While MyName <> ""
If MyName <> ThisWorkbook.Name Then
Set wb = GetObject(MyPath & MyName)
sh = Sheets("成绩表")
For Each sh In wb.Sheets
Arr = sh.Range("a2:s100")
For Each sh0 In Sheets
mm = sh0.Range("F65536").End(xlUp).Row
For k = 2 To mm
For i = 1 To UBound(Arr)
If sh0.Cells(k, 6) = Arr(i, 1) And sh0.Cells(k, 7) = Arr(i, 2) And sh0.Cells(k, 8) = Arr(i, 4) Then
For j = 9 To 18
sh0.Cells(k, j) = Arr(i, j - 3)
sh0.Cells(k, 19) = Arr(i, 17)
Next j
End If
Next i
Next k
Next
Erase Arr
Next
wb.Close False
End If
MyName = Dir
Loop
End With
Application.ScreenUpdating = True
End Sub
|
|