Clearing content from a cell (or a group) but retain its formula

D

Dr. Dirk

A cell contains a formula that produces a text when a condition is met (i.e.
produces "Played" if another cell contains a "yes").

How do I clear the content of a cell (or group of cells) that contains a
formula WITHOUT destroying (NOT removing) the formula of the cell?

A previous recommendation was to install the following macro:

Sub ClearAllSaveFormulas()
Dim cell As Range
For Each cell In Selection
With cell
If Not .HasFormula Then
.ClearContents
End If
End With
Next
End Sub

However, if the cell contains a formula, the above macro will not clear the
content of the cell.

In advance, thank you for your time and help

Dirk
 
G

Gord Dibben

Works for me.

Same as G5>Special>Constants>OK>Delete.

What "contents" do not get cleared?

The cells with formulas may return errors or true or false.

Do you wish to see nothing in the cells with formulas after clearing
contents from precedent cells?

You must trap for that in your formulas.

Post some examples of your formulas.


Gord Dibben MS Excel MVP


On Tue, 19 Jan 2010 13:59:01 -0800, Dr. Dirk <Dr.
 
G

Gord Dibben

Let me clarify further.

In A1 you have yes

In C1 your formula is =IF(A1="yes","played") returns played

Clear contents from A1 and C1 will display FALSE

If you don't want FALSE you must change your formula in C1

=IF(A1="yes","played","")


Gord
 

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