Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Clearing Row data for a given range

Thanks Chip.

Following snippet worked.

foreach (Excel.Range R in R3.Cells)
{
R.set_Value(Missing.Value, "");
}


Thans again
- Santhosh Pasupuleti

"Chip Pearson" wrote:

The following snippet works for me (XL 2007, C# 2008)

Excel.Range R1;
Excel.Range R2;
Excel.Range R3;
Excel.Worksheet WS;
int N = 10;
WS = (Excel.Worksheet)XLApp.ActiveWorkbook.Worksheets[1];
R1 = WS.get_Range("A1", "A10");
R2 = WS.get_Range("B1", "B10");
R3 = WS.get_Range("C1", "C" + N.ToString());
// Clear R1
R1.ClearContents();
// Clear R2
foreach (Excel.Range R in R2.Cells)
{
R.ClearContents();
}
// Clear R3
foreach (Excel.Range R in R3.Cells)
{
R.set_Value(Missing.Value, "");
}


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Fri, 4 Sep 2009 12:23:02 -0700, Santhosh Pasupuleti <Santhosh
wrote:

Hi,

I am trying to clear the row data keeping formatting in tact and
unfortunately the code below doesnt work. I tried using Clear contents
menthod as well as clear notes and it is of no use. Can anyone please tell me
how to delete the data keeping row formatting in tact?


ws.Rows.get_Range("A1", "Z" +
(dss.Tables[0].Rows.Count).ToString()).ClearContents();
or

Excel.Range rj;

rj = ws.Rows.get_Range("A1", "Z" +
(dss.Tables[0].Rows.Count).ToString());
rj.ClearContents();

Thanks and Regards,
Santhosh Kumar.P


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
Clearing contents from a range G. Yamada[_2_] Excel Programming 13 September 25th 08 07:45 PM
Clearing the Contents of a range of cells David A. Excel Programming 2 November 8th 07 05:59 PM
Clearing Values in a Range under certain conditions Barb Reinhardt Excel Programming 2 November 8th 06 02:24 PM
need some help clearing a range Gary Keramidas Excel Programming 4 August 18th 06 03:07 AM
Clearing a Range Ronald Cayne Excel Programming 4 September 12th 04 04:00 AM


All times are GMT +1. The time now is 02:08 PM.

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

About Us

"It's about Microsoft Excel"