Copy Range including Formats and Forumulas

A

ALV

We are trying to copy a Range to another worksheet in a C# Excel 2007 add-in
and want to get everything from the source range, including the cell formats
and formulas.

Our code is:

Excel.ListObject inTable -- is passed to the function

Excel.Range drange = inWorksheet.get_Range("A1", Type.Missing);
Excel.Range tableRange = drange;
Excel.ListColumn lcolumn = inTable.ListColumns[column];
lcolumn.Range.Copy(drange);
Excel.Range trange = drange.get_Resize(lcolumn.Range.Count, 1);
tableRange = inTable.Application.Union(tableRange, trange, Type.Missing,
Type.Missing,Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing,


The result of the copy has only the values from the source range.

Thanks.
 
A

ALV

We found the cause for this...a call to set the range style in another
function was messing up the copy.
 

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