Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
Andy Andy is offline
external usenet poster
 
Posts: 90
Default find and replace NUMBERS

hello

i have a two-column table that has text in one column like "Candy - Apples",
then numbers in the second column in the format "28-159a".

What I want to do is do a find and replace such that all the numbers and
dashes in the second column get deleted, leaving behind only the number after
the dash. I can't do a generic wildcard search for *- because it would also
delete the text and - in the first column.

Any ideas? Thank you.
Andrew
  #2   Report Post  
Posted to microsoft.public.word.tables
Helmut Weber Helmut Weber is offline
external usenet poster
 
Posts: 139
Default find and replace NUMBERS

Hi Andy,

like this:

Sub Test555()
Dim oTbl As Table
Dim oClm As Column
Dim oCll As Cell
Set oTbl = ActiveDocument.Tables(1)
Set oClm = oTbl.Columns(2)
For Each oCll In oClm.Cells
With oCll.Range.Find
.Text = "[0-9]{1,}-"
.Replacement.Text = ""
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
Next
End Sub

You may as well select the column
and loop through all cells in the selection.

Sub Test555A()
Dim oCll As Cell
For Each oCll In Selection.Cells
With oCll.Range.Find
.Text = "[0-9]{1,}-"
.Replacement.Text = ""
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
Next
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"



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
find and replace numbers using wildcards Andy Microsoft Word Help 1 May 12th 07 07:42 PM
Find multiple characters in one find using MSword find/replace Cliff Microsoft Word Help 2 October 29th 06 07:48 PM
Trying to replace words with fields using Find/Replace mbleyle Microsoft Word Help 2 March 29th 06 11:35 PM
Using find and replace or macros to replace page ranges JeremyC Microsoft Word Help 7 February 13th 06 09:20 PM
Find/ Replace is auto-capping the words I want to replace with Graham Mayor Microsoft Word Help 8 January 27th 06 01:39 AM


All times are GMT +1. The time now is 05:51 PM.

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"