I have a number of narrative descriptions that I need to categorize automatically in Excel:
Description Category
I updated the o.s.
I installed the o.s.
I cleaned valve a
I cleaned valve b
I installed valve a
Today the o.s. was updated
I have another worksheet with keywords and the category the keywords are associated with:
Keyword 1 Keyword 2 Keyword 3 Category
cleaned valve a A
installed valve a B
updated os C
installed os D
My code so far can only search one keyword at a time and therefore will report incorrect answers because some keywords are used in multiple narratives:
Public Function Test21(nar As Range, ky As Range) As String
Dim sTmp As String, vWrd As Variant, vWrds As Variant
'Splits Fsr Narrative into individual words so it can be searched for keywords'
vWrds = Split(nar)
For Each vWrd In vWrds
If Not IsError(Application.VLookup(vWrd, ky, 3, False)) Then
sTmp = Application.VLookup(vWrd, ky, 3, False)
Exit For
End If
Next vWrd
Test21 = sTmp
End Function
I've seen algorithms like this but I feel that my goal could be simpler to accomplish as all narratives are relatively simple.
Thanks for reading!