This project has moved. For the latest updates, please go here.

Copying Cell Range Fails

May 9, 2011 at 8:01 PM

I'm running into an odd error when trying to copy a cell range. I have a workbook in which I've created a worksheet and added data to it. I then create another worksheet and want to copy the headers from the first one into it. When I use a statement such as:

sheetA.Cells["1:1"].Copy(sheetB.Cells["1:1"]);

I get an out of range error indicating that the cell index is out of bounds. The odd thing is, the above call works so long as all the references are in column A. The following, for example, works fine:

sheetA.Cells["A1:A20"].Copy(sheetB.Cells["A1:A20"]);

This copies the data from the indicated cells in sheetA to sheetB. But if I include any other columns, for example:

sheetA.Cells["A1:B1"].Copy(sheetB.Cells["A1:B1"]);

I get the error again. I suspect this is a bug, but I may be doing something wrong, too. Any help you can offer would be appreciated.

Coordinator
May 10, 2011 at 6:21 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.