ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Clear contents of cells if a condition is met (https://www.excelbanter.com/excel-worksheet-functions/224451-clear-contents-cells-if-condition-met.html)

bevchapman

Clear contents of cells if a condition is met
 
I am trying to come up with a formula that will clear the contents in a range
of cells if another cell contains an X on the same row. Any suggestions?

Mike H

Clear contents of cells if a condition is met
 
Hi,

You cant have a formula in (say) A1 along the lines of

=if(b1="x",c1="")

you could do this in A1

=IF(B1="x","","No x")

which leaves A1 blank if there's an X in B1 otherwise you need a macro

Mike

"bevchapman" wrote:

I am trying to come up with a formula that will clear the contents in a range
of cells if another cell contains an X on the same row. Any suggestions?


Gord Dibben

Clear contents of cells if a condition is met
 
Formulas can return values to the cells in which they are written.

They cannot clear contents of another cell.

Are you ready for VBA?

Sub Clear_Stuff()
Dim rng As Range
With Selection
For Each rng In Selection
If rng.Value = "x" Then
rng.EntireRow.ClearContents
End If
Next rng
End With
End Sub


Gord Dibben MS Excel MVP

On Mon, 16 Mar 2009 07:51:01 -0700, bevchapman
wrote:

I am trying to come up with a formula that will clear the contents in a range
of cells if another cell contains an X on the same row. Any suggestions?




All times are GMT +1. The time now is 02:05 PM.

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