What is needed to function probaly

S

Steved

Hello from Steved

12:55 RACE 2 - 8 Jul 2009 PUKE Unknown Heavy 0.0 HghM $6000 2100
Ch : RB (MG) (JR)
and
1:30 RACE 3 - 8 Jul 2009 PUKE Unknown Heavy 0.0 R80 $8000 1200 Ch
: RB (MG) (JR)

not the below

10 RACE FOR CACHE

What is required please for the macro to function finding 12:55 RACE or
1:30 RACE but not 10 RACE Thankyou.

Sub RaceTemplate()
Selection.Find.ClearFormatting
With Selection.Find
.Text = ":"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Race"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
With Selection.Find
.Text = "^12"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.HomeKey Unit:=wdLine
Selection.MoveUp Unit:=wdLine, count:=2
Selection.TypeText Text:="win"
Selection.Range.InsertAutoText
End Sub
 
P

Pesach Shelnitz

Hi,

The following macro should find what you want to find and not find what you
don't want to find. I didn't understand what you want the macro to do when
the search string is found, so I just put in code to pop up a message so that
you can see what was found. Write back if you need any more help with your
macro.

Sub Winner()
Dim foundRange As Range
Dim wildcardsEnabled As Boolean

Selection.HomeKey wdStory
With Selection.Find
' Save status of the Match Wildcards check box
wildcardsEnabled = .MatchWildcards
.ClearFormatting
Do While .Execute(FindText:="[0-9]{1,2}:[0-9]{2}[ ^s]{1,}RACE", _
MatchWildcards:=True, _
Wrap:=wdFindStop, Forward:=True) = True
Set foundRange = Selection.Range
' Replace the next single line by the actions
' that you want to perform when the
' search string is found.
MsgBox "Found"
foundRange.Select
Selection.Collapse Direction:=wdCollapseEnd
Loop
.MatchWildcards = wildcardsEnabled
.Text = ""
End With
End Sub
 
S

Steved

Hello Pesach

I thanyou verymuch Yes this what I was trying to achieve.

"2:20 RACE"

Thankou.


Pesach Shelnitz said:
Hi,

The following macro should find what you want to find and not find what you
don't want to find. I didn't understand what you want the macro to do when
the search string is found, so I just put in code to pop up a message so that
you can see what was found. Write back if you need any more help with your
macro.

Sub Winner()
Dim foundRange As Range
Dim wildcardsEnabled As Boolean

Selection.HomeKey wdStory
With Selection.Find
' Save status of the Match Wildcards check box
wildcardsEnabled = .MatchWildcards
.ClearFormatting
Do While .Execute(FindText:="[0-9]{1,2}:[0-9]{2}[ ^s]{1,}RACE", _
MatchWildcards:=True, _
Wrap:=wdFindStop, Forward:=True) = True
Set foundRange = Selection.Range
' Replace the next single line by the actions
' that you want to perform when the
' search string is found.
MsgBox "Found"
foundRange.Select
Selection.Collapse Direction:=wdCollapseEnd
Loop
.MatchWildcards = wildcardsEnabled
.Text = ""
End With
End Sub

--
Hope this helps,
Pesach Shelnitz


Steved said:
Hello from Steved

12:55 RACE 2 - 8 Jul 2009 PUKE Unknown Heavy 0.0 HghM $6000 2100
Ch : RB (MG) (JR)
and
1:30 RACE 3 - 8 Jul 2009 PUKE Unknown Heavy 0.0 R80 $8000 1200 Ch
: RB (MG) (JR)

not the below

10 RACE FOR CACHE

What is required please for the macro to function finding 12:55 RACE or
1:30 RACE but not 10 RACE Thankyou.

Sub RaceTemplate()
Selection.Find.ClearFormatting
With Selection.Find
.Text = ":"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Race"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
With Selection.Find
.Text = "^12"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.HomeKey Unit:=wdLine
Selection.MoveUp Unit:=wdLine, count:=2
Selection.TypeText Text:="win"
Selection.Range.InsertAutoText
End Sub
 

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

Top