ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Clear Contents Of Cells Where Value = 0 (https://www.excelbanter.com/excel-worksheet-functions/149081-clear-contents-cells-where-value-%3D-0-a.html)

Carl

Clear Contents Of Cells Where Value = 0
 
My range is c10:d1000. The cells have a data link (DDE) in them. The value of
the cell can be 0 to 3000.

Could a macro clear the contents of cells were the value is 0 ?

Thank you in advance.

Mike H

Clear Contents Of Cells Where Value = 0
 
yes it could.

Right click the sheet tab and paste this in

Sub stantiate()
Dim myRange As Range
Set myRange = Range("C10:d1000")
For Each c In myRange
If c.Value = 0 Then
c.Value = ""
End If
Next
End Sub


Mike

"carl" wrote:

My range is c10:d1000. The cells have a data link (DDE) in them. The value of
the cell can be 0 to 3000.

Could a macro clear the contents of cells were the value is 0 ?

Thank you in advance.


Gord Dibben

Clear Contents Of Cells Where Value = 0
 
Sub Clear_Cells_With_Zero()
findstring = "0"
Set B = Range("C:C").Find(What:=findstring, LookAt:=xlWhole)
While Not (B Is Nothing)
B.ClearContents
Set B = Range("C:C").Find(What:=findstring, LookAt:=xlWhole)
Wend
End Sub

Without using a macro you should be able to use DataFilterAutofilter on column
C to find cells with zero and clear contents.


Gord Dibben MS Excel MVP

On Thu, 5 Jul 2007 09:24:02 -0700, carl wrote:

My range is c10:d1000. The cells have a data link (DDE) in them. The value of
the cell can be 0 to 3000.

Could a macro clear the contents of cells were the value is 0 ?

Thank you in advance.



Carl

Clear Contents Of Cells Where Value = 0
 
Hi. Thank you for helping me.

I ran the code and it got hung up he

If c.Value = 0 Then

I should have mentioned that the cell value vould be #N/A or some other
"errors".

Could this be the reason the code gets hung up ?

If so, is there a way to resolve the problem ?

Thank you in advance.

"Mike H" wrote:

yes it could.

Right click the sheet tab and paste this in

Sub stantiate()
Dim myRange As Range
Set myRange = Range("C10:d1000")
For Each c In myRange
If c.Value = 0 Then
c.Value = ""
End If
Next
End Sub


Mike

"carl" wrote:

My range is c10:d1000. The cells have a data link (DDE) in them. The value of
the cell can be 0 to 3000.

Could a macro clear the contents of cells were the value is 0 ?

Thank you in advance.



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

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