Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default 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


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
Excel: remove cell content but retain formula Cliver6 Excel Discussion (Misc queries) 2 July 15th 09 06:55 PM
How to delete/change the formula of a cell and yet retain its cont Hispanglo Sam Excel Worksheet Functions 2 February 20th 07 02:17 PM
i have a check box that keeps clearing out my cells content electromag Excel Worksheet Functions 0 September 1st 06 07:56 PM
clearing a cell and keeping the formula genevieveg New Users to Excel 5 January 12th 06 01:33 AM
Can I retain a formula in the cell pasted to? Earl Excel Worksheet Functions 1 April 19th 05 03:33 PM


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

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

About Us

"It's about Microsoft Excel"