Highliting

S

Steved

Hello from Steved

Using the examples below please what do I Need to do with the below macro,
as what it does at the moment it will highlite the next word in a paragraph
for example 15 STAR OF JUDD 3766 JUST DESERTS 25 it will highlite to DESERTS
I only want it to highlite to the last character in this case D ( JUDD )
Thankyou

15 STAR OF JUDD not 3766
14 LADY EXPRESS not 3566
9 DANZATIGER not 2063

Sub Highlighting()
Dim rPrg As Range
With Selection
.Collapse
.ExtendMode = False
Set rPrg = .Paragraphs(1).Range
End With
With rPrg.Find
.Text = "[A-Z]"
.MatchWildcards = True
.Forward = False
.Execute
rPrg.Start = Selection.Paragraphs(1).Range.Start
rPrg.HighlightColorIndex = wdYellow
End With
End Sub
 
D

Doug Robbins - Word MVP

Search for

[0-9]1,[A-Z ]{1,}[0-9]{4}

then set a range to the text that is selected then use

Range.End = Range.End - 5 to exclude the four digit number and the space
before it from the range and apply the highlight to that range.

--
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
 
S

Steved

Thankyou Doug

Doug Robbins - Word MVP said:
Search for

[0-9]1,[A-Z ]{1,}[0-9]{4}

then set a range to the text that is selected then use

Range.End = Range.End - 5 to exclude the four digit number and the space
before it from the range and apply the highlight to that range.

--
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

Steved said:
Hello from Steved

Using the examples below please what do I Need to do with the below macro,
as what it does at the moment it will highlite the next word in a
paragraph
for example 15 STAR OF JUDD 3766 JUST DESERTS 25 it will highlite to
DESERTS
I only want it to highlite to the last character in this case D ( JUDD )
Thankyou

15 STAR OF JUDD not 3766
14 LADY EXPRESS not 3566
9 DANZATIGER not 2063

Sub Highlighting()
Dim rPrg As Range
With Selection
.Collapse
.ExtendMode = False
Set rPrg = .Paragraphs(1).Range
End With
With rPrg.Find
.Text = "[A-Z]"
.MatchWildcards = True
.Forward = False
.Execute
rPrg.Start = Selection.Paragraphs(1).Range.Start
rPrg.HighlightColorIndex = wdYellow
End With
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