Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-07-2014, 06:25 PM
mrayncrental mrayncrental is offline How to search for 2 words at the same time Windows 7 64bit How to search for 2 words at the same time Office 2007
Novice
How to search for 2 words at the same time
 
Join Date: Feb 2014
Posts: 15
mrayncrental is on a distinguished road
Default How to search for 2 words at the same time

I currently have a macro that searches for "STOP:" in a table. I would like to also search for "NEXT:" at the same time (want to change the paragraph to red.

How can I do this?

See current code below. Thanks!

Code:
   Dim r As Range
    Dim Para As Paragraph
    Dim aCell As Cell
    Dim myTable As Table
    
        
'Find all Tip Paragraphs and turn red
 
  
  Selection.Find.ClearFormatting
  Selection.Find.Replacement.ClearFormatting
 
  Set myTable = ActiveDocument.Tables(1)
  For Each aCell In myTable.Columns(3).Cells
    Set r = aCell.Range
    For Each Para In aCell.Range.Paragraphs
      With Para.Range
        With .Find
            .ClearFormatting
            .Replacement.ClearFormatting
            .Text = "STOP:"
            .Format = True
            .Forward = True
            .Wrap = wdFindStop
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
            .Execute
        End With
             
        Do While .Find.Found = True
            With .Duplicate
                If .InRange(r) Then
                    .Paragraphs.First.Range.Font.Color = wdColorRed
                End If
            End With
            .Collapse wdCollapseEnd
            .Find.Execute
        Loop
      End With
    Next
   Next
 

End Sub

Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Search for date and then apply mutliple search criteria in huge dataset maxtymo Excel 2 12-01-2013 04:52 AM
2013 search results take a long time - they fill in as results in reverse date order themookman Outlook 0 10-11-2013 12:01 PM
Multiple words, one search return2300 Word VBA 0 08-30-2013 12:26 PM
How to search for 2 words at the same time Search for words starting in capitals surreytom Word VBA 3 04-01-2012 01:41 AM
How to search for 2 words at the same time Perform a search for alternative words jungkim Word 2 03-24-2012 07:40 AM

Other Forums: Access Forums

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


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