|
Private Sub CommandButton1_Click()
Set fso = CreateObject("scripting.filesystemobject")
Set d = CreateObject("scripting.dictionary")
Application.ScreenUpdating = False
Application.DisplayAlerts = False
arr = ThisWorkbook.Sheets(1).UsedRange
For j = 4 To UBound(arr)
If Len(arr(j, 2)) > 0 Then d(arr(j, 2)) = j
Next j
For Each f In fso.getfolder(ThisWorkbook.Path & "\平时成绩\").Files
With Workbooks.Open(f)
brr = .Sheets("成绩详情").UsedRange
.Close False
End With
For j = 4 To UBound(brr)
If d.exists(brr(j, 2)) Then
arr(d(brr(j, 2)), 5) = brr(j, 10)
End If
Next j
Next
ThisWorkbook.Sheets(1).UsedRange = arr
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub |
|