|
回复 12楼 dfbhy44702 的帖子
请参考:
Sub 汇总()
Dim myPath$, myFile$, sht As Worksheet
Dim arr, lr As Long, lr2 As Long
myPath = ThisWorkbook.Path & "\数学\"
myFile = Dir(myPath & "\*.xls")
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Range("e8:h65536").ClearContents
With ThisWorkbook.Sheets("Sheet1")
Do While myFile <> ""
Workbooks.Open myPath & myFile
Set sht = Sheets(1) '假设特定SHEET为第一个工作表
lr = sht.Range("d65536").End(xlUp).Row
lr2 = .Range("e65536").End(xlUp).Row + 1
arr = sht.Range("d9:g" & lr).Value
.Range("e" & lr2).Resize(UBound(arr, 1), 4) = arr
ActiveWorkbook.Close
myFile = Dir
Loop
End With
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub |
|