Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ALV ALV is offline
external usenet poster
 
Posts: 12
Default Copy Range including Formats and Forumulas

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
ALV ALV is offline
external usenet poster
 
Posts: 12
Default Copy Range including Formats and Forumulas

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

"ALV" wrote:

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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I copy a range in Excel without including hidden rows? Lang Excel Discussion (Misc queries) 1 February 22nd 08 02:48 PM
Copy Range / Including Adjacent Cells - into Existing Worksheet. [email protected] Excel Programming 1 January 14th 07 12:47 PM
custom number formats - including text from other cells Nick Smith[_2_] Excel Programming 4 April 25th 06 09:43 AM
copy range and formats to new workbook Ole[_4_] Excel Programming 0 May 18th 05 08:56 PM
Copy range and formats to new Workbook ole_ Excel Programming 4 May 18th 05 09:57 AM


All times are GMT +1. The time now is 07:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"