我正在将多个工作簿中的范围复制和粘贴到主文件中。
我在粘贴一个工作簿时遇到了麻烦,因为它告诉我复制/粘贴范围不相同。...您知道为什么会这样吗?在此之前,它可以用于其他一些工作簿,但是一旦到达第三工作簿,它就无法工作。
以下代码:
Sub MasterFile()
'OpenMF
Workbooks.Open Filename:="C:\Users\zk4h90v\Desktop\MasterFile.xlsm", UpdateLinks:=False
'AdminBase
Workbooks.Open Filename:="C:\Users\zk4h90v\Desktop\Radley Files\2019ResourcePlan-BaseAdmin-Working.xlsm", UpdateLinks:=False, ReadOnly:=True, Password:="VWMTA2019!"
Worksheets("Resource Plan").Activate
On Error Resume Next
Worksheets("Resource Plan").ShowAllData
On Error GoTo 0
Columns.EntireColumn.Hidden = False
Rows.EntireRow.Hidden = False
Workbooks("2019ResourcePlan-BaseAdmin-Working.xlsm").Worksheets("Resource Plan").Range("A4").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Workbooks("MasterFile").Activate
Workbooks("MasterFile").Worksheets("2019").Cells(Cells.Rows.Count, 2).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = False
Workbooks("2019ResourcePlan-BaseAdmin-Working.xlsm").Close SaveChanges:=False
'Epstein
Workbooks.Open Filename:="C:\Users\zk4h90v\Desktop\Radley Files\2019ResourcePlan-Epstein-Working01-09-2019.xlsm", UpdateLinks:=False, ReadOnly:=True, Password:="ccce2019"
Worksheets("Resource Plan").Activate
On Error Resume Next
Worksheets("Resource Plan").ShowAllData
On Error GoTo 0
Columns.EntireColumn.Hidden = False
Rows.EntireRow.Hidden = False
Workbooks("2019ResourcePlan-Epstein-Working01-09-2019.xlsm").Worksheets("Resource Plan").Range("A4").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Workbooks("MasterFile").Activate
Workbooks("MasterFile").Worksheets("2019").Cells(Cells.Rows.Count, 2).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = False
Workbooks("2019ResourcePlan-Epstein-Working01-09-2019.xlsm").Close SaveChanges:=False
'Deir
Workbooks.Open Filename:="C:\Users\zk4h90v\Desktop\Radley Files\2019ResourcePlan-GFCC-Working_Deirv4.xlsb", UpdateLinks:=False, ReadOnly:=True, Password:="GFCC2019rft"
Worksheets("Resource Plan").Activate
On Error Resume Next
Worksheets("Resource Plan").ShowAllData
On Error GoTo 0
Columns.EntireColumn.Hidden = False
Rows.EntireRow.Hidden = False
Workbooks("2019ResourcePlan-GFCC-Working_Deirv4.xlsb").Worksheets("Resource Plan").Range("A4").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Workbooks("MasterFile").Activate
Workbooks("MasterFile").Worksheets("2019").Cells(Cells.Rows.Count, 2).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = False
Workbooks("2019ResourcePlan-GFCC-Working_Deirv4.xlsb").Close SaveChanges:=False
'Maria
Workbooks.Open Filename:="C:\Users\zk4h90v\Desktop\Radley Files\2019ResourcePlan-GFCC-Working_Palazzotto.xlsb", UpdateLinks:=False, ReadOnly:=True, Password:="GFCC2019rft"
Worksheets("Resource Plan").Activate
On Error Resume Next
Worksheets("Resource Plan").ShowAllData
On Error GoTo 0
Columns.EntireColumn.Hidden = False
Rows.EntireRow.Hidden = False
Workbooks("2019ResourcePlan-GFCC-Working_Palazzotto.xlsb").Worksheets("Resource Plan").Range("A4").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Workbooks("MasterFile").Activate
Workbooks("MasterFile").Worksheets("2019").Cells(Cells.Rows.Count, 2).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = False
Workbooks("2019ResourcePlan-GFCC-Working_Palazzotto.xlsb").Close SaveChanges:=False
'Thummala
Workbooks.Open Filename:="C:\Users\zk4h90v\Desktop\Radley Files\2019ResourcePlan-Thummala-Working20190109.xlsm", UpdateLinks:=False, ReadOnly:=True, Password:="eit19ccor"
Worksheets("Resource Plan").Activate
On Error Resume Next
Worksheets("Resource Plan").ShowAllData
On Error GoTo 0
Columns.EntireColumn.Hidden = False
Rows.EntireRow.Hidden = False
Workbooks("2019ResourcePlan-Thummala-Working20190109.xlsm").Worksheets("Resource Plan").Range("A4").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Workbooks("MasterFile").Activate
Workbooks("MasterFile").Worksheets("2019").Cells(Cells.Rows.Count, 2).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = False
Workbooks("2019ResourcePlan-GFCC-Thummala-Working20190109.xlsm").Close SaveChanges:=False
End Sub
谢谢!