диапазон копирования / вставки не тот же: ошибка ... почему это происходит? - PullRequest
0 голосов
/ 14 февраля 2019

Я работаю над копированием и вставкой диапазонов из нескольких рабочих книг в мастер-файл.

У меня возникли проблемы при вставке одной рабочей книги, поскольку она говорит мне, что диапазон копирования / вставки не совпадает ...Знаете ли вы, почему это происходит?Он работает для нескольких других рабочих книг до этого, но не работает, когда попадает в третью рабочую книгу.

Код ниже:

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

спасибо!

...