![]() |
|
#1
|
|||
|
|||
![]()
I can't quite get the syntax right for replacing a number with the thousand separator.
Before 1266.89 3479.52 After 1,266.89 3,479.52 I tried F/R with wildcard Find: ([!/-//][0-9])([0-9]{4})(.[0-9]{2}))> Replace: \1,\2 |
#2
|
|||
|
|||
![]()
maybe just
Code:
Option Explicit Sub FormatNumbers() Dim lngdb As Long If Selection.Type = wdSelectionIP Then ActiveDocument.Range(0, 0).Select lngdb = wdFindContinue Else lngdb = wdFindStop End If With Selection.Find .ClearFormatting .Text = "[0-9]{4,}" .Replacement.Text = "" .Forward = True .Wrap = lngdb .Format = False .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True Do While .Execute Selection.Text = Format$(Selection.Text, "#,##0") If lngdb = wdFindContinue Then Selection.Collapse wdCollapseEnd Else Exit Sub End If Loop End With End Sub Last edited by pike; 10-18-2019 at 08:11 PM. |
#3
|
|||
|
|||
![]()
Thank you Pike. This will do it.
|
#4
|
|||
|
|||
![]()
no problem. Sometimes RegExp match and replace is easier than the word F/R
|
![]() |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
DavidL | Word VBA | 7 | 04-04-2018 12:01 AM |
![]() |
Natedogg | Word | 2 | 05-21-2015 07:16 AM |
![]() |
AlmostFriday | Word | 6 | 06-17-2012 05:21 AM |
![]() |
paulkaye | Word | 4 | 12-06-2011 11:05 PM |
Find & Replace Insert Issue | mipacker | Word | 0 | 02-18-2009 08:59 AM |