Home |
Search |
Today's Posts |
#13
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Clearing contents from a range | Excel Programming | |||
Clearing the Contents of a range of cells | Excel Programming | |||
Clearing Values in a Range under certain conditions | Excel Programming | |||
need some help clearing a range | Excel Programming | |||
Clearing a Range | Excel Programming |