Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.tables
|
|||
|
|||
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
Posted to microsoft.public.word.tables
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
find and replace numbers using wildcards | Microsoft Word Help | |||
Find multiple characters in one find using MSword find/replace | Microsoft Word Help | |||
Trying to replace words with fields using Find/Replace | Microsoft Word Help | |||
Using find and replace or macros to replace page ranges | Microsoft Word Help | |||
Find/ Replace is auto-capping the words I want to replace with | Microsoft Word Help |