![]() |
#2
|
||||
|
||||
![]()
Hi dmarie,
You could use a macro like the following for both problems (the second one doesn't really require a macro, but it can be easily incorporated into the one that is required for the first problem). Code:
Sub Demo() Application.ScreenUpdating = False Dim StrTxt As String With ActiveDocument.Range With .Find .ClearFormatting .Replacement.ClearFormatting .Forward = True .Wrap = wdFindStop .Format = False .MatchWildcards = True 'Fix SSNs .Text = "([0-9]{3})([0-9]{2})([0-9]{4})" .Replacement.Text = "\1-\2-\3" .Execute Replace:=wdReplaceAll 'Fix Date ranges .Text = "[0-9]{1,2}/[0-9]{1,2}/[0-9]{4}-[0-9]{1,2}/[0-9]{1,2}/[0-9]{4}" .Replacement.Text = "" .Execute End With Do While .Find.Found StrTxt = Format(Trim(Split(.Text, "-")(0)), "MMMM D, YYYY") Select Case Trim(LCase(.Words.First.Previous.Previous.Words.First)) Case "between": StrTxt = StrTxt & " and " Case "from": StrTxt = StrTxt & " to " Case "of": StrTxt = StrTxt & " through " End Select StrTxt = StrTxt & Format(Trim(Split(.Text, "-")(1)), "MMMM D, YYYY") .Text = StrTxt .Collapse wdCollapseEnd .Find.Execute Loop End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
dates, formatting-problem, number formatting |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
kjxavier | Excel | 18 | 08-23-2011 08:21 AM |
![]() |
kjxavier | Excel | 6 | 08-12-2011 05:46 AM |
Date formatting | kjxavier | Excel | 0 | 08-10-2011 08:17 AM |
![]() |
Mark Micallef | Outlook | 1 | 08-04-2010 02:38 PM |
Help needed using the serial number date with sumifs - whole office is stumped | FraserKitchell | Excel | 3 | 01-06-2010 12:24 PM |