View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
isabelle isabelle is offline
external usenet poster
 
Posts: 99
Default Search Word document based on text in Excel cell.

oops sory,
replace
n = Application.Find("green", c)
by
n = Application.Find(keywords, c)

isabelle

Le 2016-10-19 Ã* 19:24, isabelle a écrit :
Hi Ronald,

Here's an example:

Sub Macro1()
Dim keywords As String, c As Range, n As Integer
keywords = "green" ' adapt
With Worksheets(1).Range("a1:a500")
Set c = .Find(keywords, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address

Do
n = Application.Find("green", c)
With c.Characters(Start:=n, Length:=Len(keywords))
.Font.Color = RGB(255, 0, 0)
End With

Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress

End If
End With
End Sub

isabelle

Le 2016-10-19 Ã* 15:51, Ronald a écrit :
Hello all,

I have this recurrent task where I need to search trough a document for a
bunch of keywords and highlight them somehouw, preferred with a different
color. Of course I can do an Cntl-F enter text and search for it but the
keywords are too much.

Let me explain it on a easy way,

Excel: A list of cells (in one column) with keywords, say: green dog, big
cat, small bird, green tree etc.

Word: A portion of text where the spoken keywords may appear randomly.

Desired: If a keyword (actually sentence because it can have multiple words)
is found in the Word text it should be highlighted (preferrable a different
color for keyword). Would be superduper if a cell in Excel near to the
keyword would display if the keyword was found or not.

Just wanted to know if some of you experts saw somewhere a solution for this
and can tell me where to fing it. Any help would be grateful!

Cheers,

Fred.