Hello everyone-
I really hope that there is a way to do this. I am trying to code some VBA that will search for a word and then add it to a dictionary once it is found. I was able to accomplish this, however, I need my search to be more exact. Right now if I search for the word "test" it will find words like "testing" and "detest". What I would like it to do is only give me the results that have the exact word "test". Here is my code that I have now:
Does anyone know how to search for an exact match like that? Also a certain cell may have the whole phrase "This is a test" in it, but that is a valid match since the word "test" is alone. What I'm trying to say is that the cell will not just have the word "test" in it, it would have a whole sentence. That's hard to explain, hopefully that makes sense.
Anyone have any ideas? Thanks in advance!
-Mark
I really hope that there is a way to do this. I am trying to code some VBA that will search for a word and then add it to a dictionary once it is found. I was able to accomplish this, however, I need my search to be more exact. Right now if I search for the word "test" it will find words like "testing" and "detest". What I would like it to do is only give me the results that have the exact word "test". Here is my code that I have now:
Code:
Dim wordDictionary
Set wordDictionary = CreateObject("Scripting.Dictionary")
searhWord = "test"
Set searchResult = MySearchArea.Find(searchWord, LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)
If searchResult Is Nothing Then
MsgBox "Did not find anything for searchword: " & searchWord
Else
wordDictionary.Add Str(searchResult.Value)
End If
Does anyone know how to search for an exact match like that? Also a certain cell may have the whole phrase "This is a test" in it, but that is a valid match since the word "test" is alone. What I'm trying to say is that the cell will not just have the word "test" in it, it would have a whole sentence. That's hard to explain, hopefully that makes sense.
Anyone have any ideas? Thanks in advance!
-Mark