|I guess I need clarification on this question:|
Will the text to be searched contain the only the search string or will "partial searches" be required?
Any words entered into the range should be searched for. So if "Moon" Night" "time to sleep" were entered into the range, if these terms where located in the text included in Column D and E in the Raw tab, then the raw data should be filtered to show only that information.
Do the cells in Raw!D:E contains phrases that contain the search strings or are they exact matches. (I assumed you had phrases)
In other words, I assumed you are searching for alan in phrases like these:
I know a guy named Alan.
Alan is a nice guy.
I will invite Alan to my party.
I will balance the number of guys and gals at my party
If so, here is the problem with only finding alan: (We'll ignore Case at this point unless you tell me otherwise)
The .Find function in VBA is the same as the Find feature in Excel. It is either going to look for a match that matches the entire cell: lookat:=xlWhole or it's going to look for the search string anywhere in the cell: lookat:=xlPart (e.g. alan will be found in the middle of balance.)
So, if you want to find alan as part of a phrase, even if it a standalone word, we have to use lookat:=xlPart in the code. Once we use xlPart, alan will be found anywhere in the cell.
OK, so we have some options:
How about we search for " " & alan? (alan with a space in front of it)
That won't find balance, but it also won't find alan at the beginning of the phrase, only in the middle or at the end.
OK, so let's use alan & " ". (alan with a space following it)
That won't find balance, but it also won't find alan at the end of the phrase, only in the middle or at the beginning.
So how about we search once for " " & alan and once for alan & " ". That will find all standalone alan's but it will also find the ones in the middle twice since those alan's have a space before and after it. :-(
So how do we find a standalone alan when doing a Partial Search? I think it can be done by using some redundancy checking, but before I spend (waste) any time working on that, I need to know if that is actually a problem.
If the Raw data only contains an exact match for the Search strings, then just change xlPart to xlWhole and you should be good to go. If not (i.e. if it looks my examples above) then we have some work to do.
Perhaps some examples of your actual data and search strings might help.
Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.