sharky12345
Well-known Member
- Joined
- Aug 5, 2010
- Messages
- 3,425
- Office Version
- 2016
- Platform
- Windows
I'm having an issue trying to copy and paste data from another workbook - this has worked fine for years but due to a recent change in our software which produces the workbooks I'm encountering an issue.
Here's the code I'm using;
Up until recently, the source workbook was saved as an Excel 2003 file with the extension xls, but we changed our system recently and now the source files are saved as Excel 2016 files with the extension xlsx. Now I'm getting an error which fails at this line;
The error is 1004 - This action won't work on multiple selections.
If I save the source file as xls then it works fine, but generates the error if the file is saved as a xlsx file, the data is exactly the same - there are only 1165 rows of data if that is relevant.
Can anyone help me understand what is going on please?
Here's the code I'm using;
VBA Code:
Set WB = Workbooks.Open(CPFile)
WB.Sheets(1).Activate
LastDataRow = WB.Sheets(1).Range("A65536").End(xlUp).Row
WB.Sheets(1).Range("A2:E" & LastDataRow).Copy
ThisWorkbook.Worksheets("IMPORT").Activate
ThisWorkbook.Worksheets("IMPORT").Range("A2").PasteSpecial (xlPasteValues)
Up until recently, the source workbook was saved as an Excel 2003 file with the extension xls, but we changed our system recently and now the source files are saved as Excel 2016 files with the extension xlsx. Now I'm getting an error which fails at this line;
VBA Code:
ThisWorkbook.Worksheets("IMPORT").Range("A2").PasteSpecial (xlPasteValues)
The error is 1004 - This action won't work on multiple selections.
If I save the source file as xls then it works fine, but generates the error if the file is saved as a xlsx file, the data is exactly the same - there are only 1165 rows of data if that is relevant.
Can anyone help me understand what is going on please?