Only find Win*% and ignore the Win if it does not have*% after it

S

Steved

Hello from Steved

The macro below finds the word Win as in the example below but I only want
the macro to reconize the word Win if it has *% after it please, as in the
macro, please how to I ask the macro to do this Thankyou.

Fourth in No Hero's Great Western Steeplechase. Win hope, despite big weight.


Selection.Find.ClearFormatting
With Selection.Find
.Text = "Win*%"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = True
.MatchWholeWord = True
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
 
J

Jay Freedman

Hi Steve,

Your macro has .MatchWildcards = True, meaning to use wildcards. That
means the asterisk matches any sequence of characters between Win and
%, as explained in detail at
http://www.gmayor.com/replace_using_wildcards.htm. You probably don't
want to use wildcards; instead, set .MatchWildcards = False.

But the percent sign doesn't match anything in your sample text, so
the macro shouldn't find anything in the sample, with or without
wildcards.

Additionally, .MatchWholeWord = True is meaningless unless the .Text
is a single word without any punctuation characters.

Once you get the search to work correctly, there's another wrinkle. If
you just want to find (and select) the .Text item, the macro is ok. If
you want to replace it -- in this case, replace it with nothing, which
is equivalent to deleting it -- you need to supply a value for the
optional parameter Replace of the .Execute method:

Selection.Find.Execute Replace:=wdReplaceOne

or

Selection.Find.Execute Replace:=wdReplaceAll

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
S

Steved

Hello Jay from Steved

Thanks for your time on my issue below is what I am trying to acheive you
will notice Win and Win 16% which is what I am hoping to do.


Fourth in No Hero's Great Western Steeplechase. Win hope, despite big weight.
2 x8096 Kalsoy (AUS) (5) 12g b
Mister C. (USA)-Miss Epicure (AUS) (by Without Fear)
Tane Belsham 65kg (R98)
White, royal blue stars, royal blue & white hooped sleeves, white cap
Stats:
Trainer: John & Teria McKay (Wyndham)
Owner: L I Redshaw
All 108:17:12:13:10
Prz $127,425
Win 16%
Plc 39% L 108:17:25
R 0:0:0
F 0:0:0
G 24:0:5
D 33:4:7
S 34:6:11
 
J

Jay Freedman

Hi Steve,

The full sample makes a big difference. You still haven't made clear
whether you want to just FIND the text or REPLACE the text, but I
already explained how to handle that.

To find the word Win followed by a space, a number, and a percent
sign, you do need a wildcard search, meaning you should keep the
..MatchWildcards = True statement in the macro. The .Text expression
should be

.Text = "Win [0-9]{1,}%"

In this expression, the [0-9] means "any digit" and the {1,} means
"one or more of those digits". The Win and the % will match those
literal characters.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
S

Steved

Hello Jay from Steved

I am comfortable with what needs to be done in this case I'm Deleting.

Thanks for taking timeout.

Jay Freedman said:
Hi Steve,

The full sample makes a big difference. You still haven't made clear
whether you want to just FIND the text or REPLACE the text, but I
already explained how to handle that.

To find the word Win followed by a space, a number, and a percent
sign, you do need a wildcard search, meaning you should keep the
..MatchWildcards = True statement in the macro. The .Text expression
should be

.Text = "Win [0-9]{1,}%"

In this expression, the [0-9] means "any digit" and the {1,} means
"one or more of those digits". The Win and the % will match those
literal characters.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

Hello Jay from Steved

Thanks for your time on my issue below is what I am trying to acheive you
will notice Win and Win 16% which is what I am hoping to do.


Fourth in No Hero's Great Western Steeplechase. Win hope, despite big weight.
2 x8096 Kalsoy (AUS) (5) 12g b
Mister C. (USA)-Miss Epicure (AUS) (by Without Fear)
Tane Belsham 65kg (R98)
White, royal blue stars, royal blue & white hooped sleeves, white cap
Stats:
Trainer: John & Teria McKay (Wyndham)
Owner: L I Redshaw
All 108:17:12:13:10
Prz $127,425
Win 16%
Plc 39% L 108:17:25
R 0:0:0
F 0:0:0
G 24:0:5
D 33:4:7
S 34:6:11
 

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