If cell = "0", then clear the cell

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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 there:

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

Any help would be great!!!
 
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)?
 
THANK YOU!!! It worked...

Dave R. said:
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)?
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top