Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.newusers
Larry Larry is offline
external usenet poster
 
Posts: 115
Default Finding numbers with or without commas

Using Word's Search and Replace function, how would I find all numbers in a
document, whether they are separated into columns by commas or not?

Such as 5 or 100 or 1,100 or 2,300,000

I've tried everything I could think of, using the [ ] and {1,} syntax and
can't get it.

I'm working with Word 97.

Thanks

Larry

  #2   Report Post  
Posted to microsoft.public.word.newusers
macropod[_2_] macropod[_2_] is offline
external usenet poster
 
Posts: 2,059
Default Finding numbers with or without commas

Hi Larry,

You could use:
[0-9,.]{1,}
with the 'use wildcards' option checked. This will find decimals too.

Note that, because Find/Replace treats the commas as word delimiters, executing the above Find expression on, say, 10,000.01 will
first find 10,000.01, then 000.01 and, finally, 01

--
Cheers
macropod
[Microsoft MVP - Word]


"Larry" wrote in message ...
Using Word's Search and Replace function, how would I find all numbers in a
document, whether they are separated into columns by commas or not?

Such as 5 or 100 or 1,100 or 2,300,000

I've tried everything I could think of, using the [ ] and {1,} syntax and
can't get it.

I'm working with Word 97.

Thanks

Larry


  #3   Report Post  
Posted to microsoft.public.word.newusers
Larry Larry is offline
external usenet poster
 
Posts: 115
Default Finding numbers with or without commas

You could use:
[0-9,.]{1,}
with the 'use wildcards' option checked. This will find decimals too.


Macropod,

Thanks.

It finds all the numbers except for 2,300,000.

Odd. If it finds 1,100 why doesn't it find 2,300,000?

Also, I don't need to find decimals with this search. I'm only dealing with
round numbers.

Another oddity: it opened the footer of the document and found the page
number in there.

Larry

  #4   Report Post  
Posted to microsoft.public.word.newusers
macropod[_2_] macropod[_2_] is offline
external usenet poster
 
Posts: 2,059
Default Finding numbers with or without commas

Hi Larry,

The problem was that the Find expression disallows numbers followed by a period.

Try using:
[0-9,.]{1,}
instead.

--
Cheers
macropod
[Microsoft MVP - Word]


"Larry" wrote in message ...
You could use:
[0-9,.]{1,}
with the 'use wildcards' option checked. This will find decimals too.


Macropod,

Thanks.

It finds all the numbers except for 2,300,000.

Odd. If it finds 1,100 why doesn't it find 2,300,000?

Also, I don't need to find decimals with this search. I'm only dealing with
round numbers.

Another oddity: it opened the footer of the document and found the page
number in there.

Larry

  #5   Report Post  
Posted to microsoft.public.word.newusers
Larry Larry is offline
external usenet poster
 
Posts: 115
Default Finding numbers with or without commas

I didn't mention before, I'm looking for numbers preceded by the British
symbol for pounds, like

£3,500

I kept playing with it and got something which is almost there but not
quite.

This code

^0163([0-9,]{1,})

works, with one exception. If the number is followed by a comma, the Search
finds the comma as well. This seems unavoidable, given that I'm looking for
commas inside the number. How then can I keep it from finding a comma after
the number? I've tried a bunch of things, can't get it to find the number
while not finding the comma following the number.



  #6   Report Post  
Posted to microsoft.public.word.newusers
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Finding numbers with or without commas

In this case you are going to have to use a macro to eliminate the unwanted
extra characters. The following will find only the numbers and the pound
sign (that can be eliminated from the found string also by removing the
quote from the start of the indicated line.). You haven't said what you want
to do with the found strings, so the macro merely displays them in message
boxes:

Sub FindCashAmounts()
Dim oRng As Range
With Selection
.HomeKey wdStory
With .Find
While .Execute(findText:="£[0-9,.]{1,}", MatchWildcards:=True)
Set oRng = Selection.Range
Select Case oRng.Characters.Last
Case Is = ",", "."
oRng.End = oRng.End - 1
Case Else
End Select
'Next line removes the £ sign from the found string
'If oRng.Characters.First = "£" Then _
oRng.Start = oRng.Start + 1
'do what you want with the found text here e.g.
MsgBox oRng
Wend
End With
End With
End Sub

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

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Larry wrote:
I didn't mention before, I'm looking for numbers preceded by the
British symbol for pounds, like

£3,500

I kept playing with it and got something which is almost there but not
quite.

This code

^0163([0-9,]{1,})

works, with one exception. If the number is followed by a comma, the
Search finds the comma as well. This seems unavoidable, given that
I'm looking for commas inside the number. How then can I keep it from
finding a comma after the number? I've tried a bunch of things, can't
get it to find the number while not finding the comma following the
number.



  #7   Report Post  
Posted to microsoft.public.word.newusers
Larry Larry is offline
external usenet poster
 
Posts: 115
Default Finding numbers with or without commas

I think what I want is not possible with a simple search. I think I'm going
to have to create a macro which stops after each find and retracts the
selection from the comma if there is one.

  #8   Report Post  
Posted to microsoft.public.word.newusers
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Finding numbers with or without commas

I guess our messages crossed in transit?

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


Larry wrote:
I think what I want is not possible with a simple search. I think I'm
going to have to create a macro which stops after each find and
retracts the selection from the comma if there is one.



  #9   Report Post  
Posted to microsoft.public.word.newusers
Larry Larry is offline
external usenet poster
 
Posts: 115
Default Finding numbers with or without commas

I guess our messages crossed in transit?

Yes, we had the same thought. Thanks for the code.

Larry

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Word 2007: Finding section numbers Mz_Kitty Microsoft Word Help 1 July 23rd 08 09:45 PM
I inverted commas in don't appear on the first key hit. Help? Gary Hastie Microsoft Word Help 1 October 2nd 06 07:00 AM
Word Merge Document from Excel - numbers not printing with commas Judy Mailmerge 1 February 17th 06 05:42 AM
Formatting numbers in a table commas & dollar signs Butler Tables 1 April 15th 05 06:40 PM
Can't use commas!!! Becky Microsoft Word Help 2 February 25th 05 06:05 PM


All times are GMT +1. The time now is 01:18 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"