ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Clearing content from a cell (or a group) but retain its formula (https://www.excelbanter.com/excel-discussion-misc-queries/253813-clearing-content-cell-group-but-retain-its-formula.html)

Dr. Dirk

Clearing content from a cell (or a group) but retain its formula
 
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

Gord Dibben

Clearing content from a cell (or a group) but retain its formula
 
Works for me.

Same as G5SpecialConstantsOKDelete.

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.
wrote:

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



Gord Dibben

Clearing content from a cell (or a group) but retain its formula
 
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

On Tue, 19 Jan 2010 14:12:19 -0800, Gord Dibben <gorddibbATshawDOTca wrote:

Works for me.

Same as G5SpecialConstantsOKDelete.

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.
wrote:

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




All times are GMT +1. The time now is 09:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com