![]() |
Find a single "0" (zero) in find command
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 *** |
Find a single "0" (zero) in find command
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) "ogopogo5" wrote: 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 *** |
Find a single "0" (zero) in find command
Hi Joel
Thank you very much for the help. I copied and paste your code and it works great. Once again, thank you. Ogopogo5 *** Sent via Developersdex http://www.developersdex.com *** |
All times are GMT +1. The time now is 07:50 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com