Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-16-2015, 01:52 AM
PRA007's Avatar
PRA007 PRA007 is offline Find Multiple Wildcard string and Highlight Windows 7 32bit Find Multiple Wildcard string and Highlight Office 2010 32bit
Competent Performer
Find Multiple Wildcard string and Highlight
 
Join Date: Dec 2014
Location: Ahmedabad, Gujrat, India
Posts: 145
PRA007 is on a distinguished road
Default Find Multiple Wildcard string and Highlight

I want to highlight two identical string if present in word document to be highlighed

For example in my word table there are somuch data with some patent numbers
I would like to find the duplicate patent numbers and want to highlight

Specific example

I have string like this

1. WO 12345 A1
2. US 12345 A2


3. EP 12345 A1
4. WO 12345 A1
5. WO 12345 A3
6. US 12345 A2

Note that above strings are distributed in tables with other data

I want to highlight strings which have [A-Z]{2} [0-9]{4,} duplicate.
Reply With Quote
  #2  
Old 10-16-2015, 02:25 PM
macropod's Avatar
macropod macropod is offline Find Multiple Wildcard string and Highlight Windows 7 64bit Find Multiple Wildcard string and Highlight Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim strTxt As String, i As Long
strTxt = "|"
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "[A-Z]{2} [0-9]{4,}"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    .Execute
  End With
  Do While .Find.Found
    If InStr(strTxt, "|" & .Text & "|") = 0 Then
      strTxt = strTxt & .Text & "|"
    Else
      i = i + 1
      .HighlightColorIndex = wdYellow
    End If
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
Application.ScreenUpdating = True
MsgBox i & " duplicates found."
End Sub
Note: I've used the Find expression you specified, but that doesn't test the suffixes. You can decide whether that returns false matches.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 10-17-2015, 01:07 AM
PRA007's Avatar
PRA007 PRA007 is offline Find Multiple Wildcard string and Highlight Windows 7 32bit Find Multiple Wildcard string and Highlight Office 2010 32bit
Competent Performer
Find Multiple Wildcard string and Highlight
 
Join Date: Dec 2014
Location: Ahmedabad, Gujrat, India
Posts: 145
PRA007 is on a distinguished road
Default

This is really great and sufficient
Thanks
Reply With Quote
Reply

Tags
word table, word vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find Multiple Wildcard string and Highlight Find and highlight multiple words in MS Word document AtaLoss Word VBA 37 09-22-2021 12:04 PM
Find Multiple Wildcard string and Highlight Find/Replace Wildcard Needed-Bold & Highlight rsrasc Word VBA 3 11-11-2014 03:55 PM
Find and highlight multiple words in a document flatop Word VBA 3 04-16-2014 10:29 PM
Extract from String using Wildcard whousedmy Word 0 05-21-2009 01:35 AM
find - reading highlight - highlight all / highlight doesn't stick when saved bobk544 Word 3 04-15-2009 03:31 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:52 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft