A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
This error occurs when the copy area and paste area are not the same size. In your code, you are copying the entire worksheet and pasting it into a new workbook. This can cause issues if the new workbook has a different number of rows or columns than the original worksheet.
To resolve this issue, you can try selecting a specific range to copy and paste instead of copying the entire worksheet. You can also try adjusting the size of the paste area to match the size of the copy area.
Here's an example of how to copy and paste a specific range:
=================================
wkSheet.Range("A1:AH84").Copy();
newWorkbook.Worksheets[1].Range("A1:AH84").PasteSpecial(ExcelAPI.XlPasteType.xlPasteValues, ExcelAPI.XlPasteSpecialOperation.xlPasteSpecialOperationNone, false, false);
=================================
In this example, we are copying the range A1:AH84 from the original worksheet and pasting it into the first worksheet of the new workbook. You can adjust the range to match the size of your data.