View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Sharad Vyas Sharad  Vyas is offline
external usenet poster
 
Posts: 7
Default Maintaining formula while clearing the cell

Great.While trying this
Range.SpecialCells(xlCellTypeConstants).Clear();
Range.SpecialCells has two parameter second one is value of type object,
what should i use for that?


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Sharad,

Write your formulas to return "" if their input cell is blank:

You have
=Formula

Change to
=IF(B6<"",Formula,"")

and then don't delete your formulas, perhaps by changing

Range.Clear()

to

Range.SpecialCells(xlCellTypeConstants).Clear()

HTH,
Bernie
MS Excel MVP


"Sharad Vyas" wrote in message
...
I am working with VSTO with C#. My worksheet has 10 Columns and many nows.
Some of the cell contains formula and other are populated with data from
the data source.I define formating, formulas and fill in all cells with 0s
(where there is no formula). I have to compute Meaid across the column for
each row. When I load the data, it dictates whether I will have 2 or 4 or
all 10 columns filled in. Once I load the data (lets say 4 columns),
programatically I clear the remaining 6 columns. All works fine until this
point. If I change some parameter and reload the data in the same session,
and lets say it has (5 columns) more than 4 columns this time, all the
cells , which had formula, for 5th columns, remains null. Data load is
just fine. The reason for this issue is that when I cleared the 6 columns
during my first data loas, it cleared my formula too.

My quesitons is how can I maitain/keep the formula, which I set in the
Excel, whiling Clearing the cell programtically. As I said I am using C#
with VSTO and using Excel object model;s Range.Clear() method to clear
the cell.

Help greatly appreiciated!!
-Sharad