![]() |
#2
|
||||
|
||||
![]()
Since it is a macro it doesn't matter if it takes a few extra passes
Code:
Sub DPU_TimeFormat() Dim Rng As Range Application.ScreenUpdating = False Set Rng = ActiveDocument.Range With Rng.Find .MatchWildcards = True 'Delete periods in a.m./p.m. .Text = "([0-9]) ([APap]).([mM])." 'with space between number and a/p .Replacement.Text = "\1\2\3" .Execute Replace:=wdReplaceAll .Text = "([0-9]) ([APap]).([mM])" .Replacement.Text = "\1\2\3" .Execute Replace:=wdReplaceAll .Text = "([0-9]) ([APap])([mM])>" 'without space between number and a/p .Replacement.Text = "\1\2\3" .Execute Replace:=wdReplaceAll .Text = "([0-9])AM>" 'AM to am .Replacement.Text = "\1am" .Execute Replace:=wdReplaceAll .Text = "([0-9])PM>" 'PM to pm .Replacement.Text = "\1pm" .Execute Replace:=wdReplaceAll 'Change period for colon in times .Text = "([0-9]{1,2}).([0-9]{2})([ap])m" .Replacement.Text = "\1:\2\3m" .Execute Replace:=wdReplaceAll End With Application.ScreenUpdating = True End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Format number for time , hh:mm:ss,,,second appears 00 | yoshi | Excel | 4 | 04-26-2021 03:11 AM |
![]() |
jiaron_1230 | Word VBA | 3 | 11-15-2016 05:15 AM |
![]() |
tmeck63 | Project | 1 | 01-07-2016 09:11 PM |
time in minute format | orajesh | Excel | 3 | 12-15-2015 12:56 AM |
Changing format of time data | Sammael | Excel | 2 | 04-08-2012 12:13 PM |