ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   If cell = "0", then clear the cell (https://www.excelbanter.com/excel-discussion-misc-queries/1969-if-cell-%3D-%220%22-then-clear-cell.html)

One-Leg

If cell = "0", then clear the cell
 
Hello,

I would like to use a macro that will allow me to select the range A2 to
A65536 and every cells with a value that equals "0" must be cleared.

I don't wanna use the Find/Replace feature cause it removes the "0" from the
other cells and I really need them to remain intact. Here is an idea of what
I have:


A2: 4852035
A3: 8563201
A4: 4845625
A5: 4842562
....
A325: 4521023
A326: 4120001
A327: 7841036
A328: 0
A329: 0
A330: 0
....
A65534: 0
A65535: 0
A65536: 0


The cells having only a "0" in them will change all the time. One minute
it's from A328 to A65536 and the next, it's from A378 to A65536 (my file
updates itself from an SWL database.

I used the following form in my macro but my "0" stayed the

Range("A2:A65536").Select
If Cells.Select = 0 Then Selection.ClearContents

Any help would be great!!!

Dave R.

You are looking for VBA, but can't you just check the box for "match entire
cell contents" when doing a find and replace (it's under the options button
after pressing CTRL-H)?


"One-Leg" wrote in message
...
Hello,

I would like to use a macro that will allow me to select the range A2 to
A65536 and every cells with a value that equals "0" must be cleared.

I don't wanna use the Find/Replace feature cause it removes the "0" from

the
other cells and I really need them to remain intact. Here is an idea of

what
I have:


A2: 4852035
A3: 8563201
A4: 4845625
A5: 4842562
...
A325: 4521023
A326: 4120001
A327: 7841036
A328: 0
A329: 0
A330: 0
...
A65534: 0
A65535: 0
A65536: 0


The cells having only a "0" in them will change all the time. One minute
it's from A328 to A65536 and the next, it's from A378 to A65536 (my file
updates itself from an SWL database.

I used the following form in my macro but my "0" stayed the

Range("A2:A65536").Select
If Cells.Select = 0 Then Selection.ClearContents

Any help would be great!!!




One-Leg

THANK YOU!!! It worked...

"Dave R." wrote:

You are looking for VBA, but can't you just check the box for "match entire
cell contents" when doing a find and replace (it's under the options button
after pressing CTRL-H)?


"One-Leg" wrote in message
...
Hello,

I would like to use a macro that will allow me to select the range A2 to
A65536 and every cells with a value that equals "0" must be cleared.

I don't wanna use the Find/Replace feature cause it removes the "0" from

the
other cells and I really need them to remain intact. Here is an idea of

what
I have:


A2: 4852035
A3: 8563201
A4: 4845625
A5: 4842562
...
A325: 4521023
A326: 4120001
A327: 7841036
A328: 0
A329: 0
A330: 0
...
A65534: 0
A65535: 0
A65536: 0


The cells having only a "0" in them will change all the time. One minute
it's from A328 to A65536 and the next, it's from A378 to A65536 (my file
updates itself from an SWL database.

I used the following form in my macro but my "0" stayed the

Range("A2:A65536").Select
If Cells.Select = 0 Then Selection.ClearContents

Any help would be great!!!





Dave R.

No problem. Here is a VBA solution as well, you'll have to select cells
first.

Sub fook()
Dim cell As Range
For Each cell In Selection
If cell.Value = 0 Then
cell.Clear
End If
Next
End Sub



"One-Leg" wrote in message
...
THANK YOU!!! It worked...

"Dave R." wrote:

You are looking for VBA, but can't you just check the box for "match

entire
cell contents" when doing a find and replace (it's under the options

button
after pressing CTRL-H)?


"One-Leg" wrote in message
...
Hello,

I would like to use a macro that will allow me to select the range A2

to
A65536 and every cells with a value that equals "0" must be cleared.

I don't wanna use the Find/Replace feature cause it removes the "0"

from
the
other cells and I really need them to remain intact. Here is an idea

of
what
I have:


A2: 4852035
A3: 8563201
A4: 4845625
A5: 4842562
...
A325: 4521023
A326: 4120001
A327: 7841036
A328: 0
A329: 0
A330: 0
...
A65534: 0
A65535: 0
A65536: 0


The cells having only a "0" in them will change all the time. One

minute
it's from A328 to A65536 and the next, it's from A378 to A65536 (my

file
updates itself from an SWL database.

I used the following form in my macro but my "0" stayed the

Range("A2:A65536").Select
If Cells.Select = 0 Then Selection.ClearContents

Any help would be great!!!








All times are GMT +1. The time now is 11:39 AM.

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