forked from aaronkeene/ExcelVBA
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindKeyword.vb
More file actions
27 lines (22 loc) · 797 Bytes
/
FindKeyword.vb
File metadata and controls
27 lines (22 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Function FindKeyword( _
WordList As Range, _
TextString As Range)
'Finds keywords in a text string from a user supplied list of words.
Dim Word As Range
'Test each word in the provided WordList against TextString '
For Each Word In WordList
'If a word is foun, add it to the result
If InStr(1, TextString, Word, 1) > 0 Then
If IsEmpty(FindKeyword) Then
FindKeyword = Word
Else
'If more than one word is found, result is deliminated with commas
FindKeyword = FindKeyword & ", " & Word
End If
End If
Next Word
'Reuturn "" when no words arefound in the TextString
If FindKeyword = 0 Then
FindKeyword = ""
End If
End Function