View Single Post
 
Old 10-29-2012, 07:49 AM
mpdsal mpdsal is offline Windows XP Office 2007
Novice
 
Join Date: Nov 2011
Posts: 19
mpdsal is on a distinguished road
Default Help with VBA code to find and highlight text

I did a search before posing this but did not find a solution for my particular request.

I have the following code which is working beautifully however I want not only the found words to be highlighted but all the text in that row, which may include spaces and text. For example, after I find Procedure Step: I want it to highlight all the information following it.

Procedure Step: Inbound Staging
Procedure Step: FIFO

Here is the code I have so far:

Code:
Sub Highlight_Word()
Dim sFindText As String
'Start from the top of the document
Selection.HomeKey wdStory
sFindText = "Procedure Step:"
Selection.Find.Execute sFindText
Do Until Selection.Find.Found = False
  Selection.Range.HighlightColorIndex = wdYellow
  Selection.MoveRight
  Selection.Find.Execute
Loop
End Sub
Thanks
Mark

Last edited by macropod; 10-29-2012 at 02:40 PM. Reason: Added code tags & formatting
Reply With Quote