|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Paste是工作表方法,应该改为:
sum.Paste
sum必须是当前工作表:
ThisWorkbook.Activate
sum.Activate
sum.Cells(myirow, 1).Activate
sum.Paste
仅复制数据,可用数组:
Sub Testing()
Application.ScreenUpdating = False
Application.EnableEvents = False
Dim wb, ws, sum, mypath, myfile, sh, myirow, newirow, lastr, Arr()
t = Timer
Set sum = ThisWorkbook.Sheets("Summary")
mypath = ThisWorkbook.Path & "\Consolidation\"
myfile = Dir(mypath & "*.xlsx")
Do While myfile <> ""
Set wb = Workbooks.Open(mypath & myfile, 0)
With wb.Sheets("sheet2")
Arr = Range("a3:a6").Value
myirow = sum.Range("A2").End(xlDown).Row + 1
sum.Cells(myirow, 1).Resize(4, 1).Value = Arr
End With
wb.Close False
myfile = Dir
Loop
Set wb = Nothing
Application.EnableEvents = True
Application.ScreenUpdating = True
MsgBox "Complete", , "Running Time: " & Format(Timer - t, "#0.000") & " " & "second"
End Sub
|
评分
-
1
查看全部评分
-
|