Find a single "0" (zero) in find command

O

ogopogo5

I wrote this code and I wanted it to find and delete any single "0"
(zero). However it is deleting any numbers with zeros, I.E. 10, 100,
150, 10,275 etc. Is there a way to write it so it will find a single
"0"? The following is the code I wrote.

Sub FindZero
For x = 1 To 6
Dim rngFound As Range

Set rngFound = Cells.Find(What:="0", After:=ActiveCell, _
LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False,
SearchFormat:=False)
If Not rngFound Is Nothing Then
rngFound.Select
Selection.Clear
End If
Next x
End Sub

Ogopogo5

*** Sent via Developersdex http://www.developersdex.com ***
 
J

Joel

add lookat:=xlwhole to you find command

Set rngFound = Cells.Find(What:="0", After:=ActiveCell, _
LookIn:=xlFormulas, LookAt:=xlwhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False,
SearchFormat:=False)
 

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

Top