How Find 0 but not 0.5

  • Thread starter Thread starter Jay
  • Start date Start date
J

Jay

I am using Microsoft Word 2002. I have a table of numerical values that range
mostly from 0 to 9. But occasionally I have to include the value 0.5
(one-half).


At times I want to eliminate all the whole number zeros and replace them
with blank spaces. I know how to do this with the find/replace function, but
the problem is when I do this it also eliminates the leading zero on any of
my 0.5 values.

I only want to replace any whole number zeros, not the zero in 0.5. Does
anyone know how to accomplish this?

Thanks
 
Thanks for responding do you mean to place the term 0^p
in the FIND box?

Is the (zero plus paragraph mark) you refer to the 3 characters of 0^p

I tried placing the term 0^p in the FIND box, and after I click the
REPLACE ALL button I get the warning that ^p is not a valid special
character.

Can you explain a little further.

THANKS AGAIN
 
PJY thanks for responding. But do you mean to place the term 0^p
in the FIND box?

Is the (zero plus paragraph mark) you refer to the 3 characters of 0^p

I tried placing the term 0^p in the FIND box, and after I click the
REPLACE ALL button I get the warning that ^p is not a valid special
character.

Can you explain a little further.

THANKS AGAIN
 
Yes, that's exactly what I mean - (I'm using 2003) in the Find box put a zero
(0) in the find spot, then go to more, then special (in your find box) select
paragraph mark (^p) and place that directly next to the zero in the find box.
The only thing I can think of why it is not working is the difference in our
versions - it worked perfectly for me
 
Before I was typing in 0^p while having the Use Wildcard box checked.
Maybe thats why I recv that error. Anyway I found the paragraph mark under
the special drop down list.

I used that after the zero and when I clicked Replace All, its says 0
replacements were made.

So know it is not finding the individual zeros when I have the 0^p in
the FIND box.

Any ideas?
 
Unfortunately, end of cell markers are not identifable with Find and Replace
so you'll either need to use VBA or do it as a three stage process:

1. Find all "0." sequences and change them to some unique sequence not found
elsewhere in the document.
2. Change all (remaining) "0" characters as you wish
3. Replace all (whatever sequence you chose in step 1) with "0."
 
Tony...I thought about your way and it is an xtra step but works for me.

First I replaced all instances of 0.5 to the dollar sign($). Then I replaced
all whole number zeros to blank spaces then went back and replaced all dollar
signs with 0.5


Thanks again


Wish there was a way to recognize only the whole number zero and not when it
is used as a place holder in a decimal.
 
You can't use ^p with wildcards use ^13 instead -
http://www.gmayor.com/replace_using_wildcards.htm
However if the numbers are in a table there will probably not be a paragraph
mark after the number so this won't work either. And using replace I foresee
all sorts problems. I suggest a macro would be the better way forward

Sub RemoveZeros()
Dim aTextDoc As Document
Dim cTable As Table
Dim rName As Range
Dim i As Long
Dim j As Long

Set aTextDoc = ActiveDocument
Set cTable = aTextDoc.Tables(1)

For i = 1 To cTable.Rows.Count
For j = 1 To cTable.Columns.Count
Set rName = cTable.Cell(i, j).Range
rName.End = rName.End - 1
If Len(rName) = 1 Then
If rName.Text = "0" Then
rName.Delete
End If
End If
Next j
Next i
End Sub

Will remove entries of 0 from table cells where the cell only contains 0
without affecting cells that contain 0.5 or 10 etc.
The macro checks each cell in each row to see if it contains one character
if it does then it checks whether that character is 0 and if it is it
deletes it.

http://www.gmayor.com/installing_macro.htm


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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