![]() |
#6
|
||||
|
||||
![]()
Try this code. Note that the hyphen isn't a plain hyphen - it is an n-dash which has an Asc value of 150. A regular hyphen has an Asc value of 45.
Code:
Sub FindPattern() Dim aRng As Range, str As String, int1 As Integer, int2 As Integer, arrStr() As String Set aRng = ActiveDocument.Range With aRng.Find .ClearFormatting .MatchWildcards = True .Text = "[0-9]{3}–[0-9]{1}" Do While .Execute = True arrStr = Split(aRng.Text, "–") int1 = CInt(arrStr(0)) + 2 int2 = CInt(arrStr(1)) + 2 aRng.Text = int1 & "-" & int2 aRng.Collapse Direction:=wdCollapseEnd aRng.End = ActiveDocument.Range.End Loop End With End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Marcia | Excel Programming | 5 | 05-04-2020 05:15 AM |
![]() |
wardw | Word | 7 | 05-07-2018 09:13 AM |
![]() |
puff | Word | 2 | 02-28-2018 11:04 AM |
![]() |
Anthon | Excel Programming | 1 | 11-03-2016 12:48 AM |
How to do multiple find and replace in string. | PRA007 | Word VBA | 2 | 01-06-2016 09:10 PM |