VBA Excel将特定工作表中的数据复制到另一个工作簿中的特定工作表

时间:2014-02-26 20:21:26

标签: excel vba excel-vba

我需要编写一个MACRO,将特定工作表中的表复制到主工作簿中的第一个空行中的特定工作表(工作表3)。

理想情况下,我希望将MACRO应用于特定文件夹中的所有文件。从不同的工作簿中提取一个名为“Sheet 3”的工作表。 (“表3”只是一个占位符)

这是我到目前为止所做的:

Sub Master()
Application.ScreenUpdating = False
Dim erow

Workbooks.Open Filename:= "C:\Example\File.xlsx"
Sheets("Sheet 3").Select
Range("A2").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
ActiveWorkbook.Close

Workbooks("MASTER").Sheets("Sheet 3").Activate 
'MASTER is the name of the Master Workbook
erow = Sheets("Sheet 3").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

Selection.Paste 
'This is where the MACRO gives a "Run-time error '438': Object doesn't support
'this property or method"

Application.ScreenUpdating = True
End Sub

任何帮助将不胜感激!

0 个答案:

没有答案
相关问题