This should be a super-simple task, but I'm tearing my hair out due to Run-time Error 5, no matter what I try!
I am trying to fill an array with individual words from a cell containing text. I already have code working that finds each word in succession. But before adding each new word to the array, I need to check that that word doesn't already exist within the array.
I started off trying to use COUNTIF, but that only works on a range, not on an array.
Latest iteration is:
If IsError(WorksheetFunction.Match(NewWord, WordArray, 0) then
where NewWord is a string variable containing the latest word, and WordArray is a variant array which will store the words.
What am I doing wrong? Why does this give me a runtime error?
I should note that when I get this error (on the very first word), NewWord is a string such as "flower" and WordArray is empty (having just been ReDim-ed as WordArray(6)).