XL2007: Copying worksheets between workbooks

J

Josh Sale

I have some reliable old code that copies worksheets between workbooks
more or less like this:

thisWorkbook.ActiveSheet.Copy after:=thatWorkbook.Worksheets(1)

When I do the copy I want to make sure I get the cell contents,
formatting, validations, any macros in the worksheet's code module,
etc. In other words I want it all.

Sadly I can't reliably count on the Copy method anymore because of the
new workbook formats with their underlying changes in row & column
counts. If thisWorkbook is an XLS and thatWorkbook is an XLSX the
Copy fails.

Obviously it can be a problem copying from an XLSX to an XLS if the
source worksheet contains more rows or columns than the target can
hold and I'm OK with that.

Can somebody suggest an alternative coding technique to replace the
Copy method?

TIA,

josh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top