Remove duplicate time entries

S

Spotty Boy

Hi,

I am trying to replace a particular string in a simple file and cannot
seem to get it to work. There are no errors but all the time entries
are replaced. Ultimately, I want to delete only the redundant time
entries. This is a MS Word 2003 VB Macro. I've seen so much
contradictory junk that I'm lost and the MS documentation is certainly
no help ... Thanks in advance for any ideas ...

EXAMPLE FILE:

MONDAY
00:00
01:01
TUESDAY
03:24
03:24
03:28
WEDNESDAY
04:12
04:13
07:23
THURSDAY
00:30
00:30

CODE:

Sub deltime()
'
' test5 Macro to Delete redundant time entries
Selection.Find.MatchWildcards = True
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
'
With Selection.Find
.Text = "[0-9][0-9]:[0-9][0-9]"
.Forward = True
.Wrap = wdFindContinue
If Selection.Text = "03:24" Then
Selection.Find.Replacement.Text = "ABC"
End With
'
Selection.Find.Execute Replace:=wdReplaceAll
'
End Sub
 
D

Doug Robbins - Word MVP

Use:

With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.MatchWildcards = True
.Text = "(*^13)@"
.Replacement.Text = "\1"
.Forward = True
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top