View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Finding a word in a cell, but not when its a substring of another word in the cell

Derrick,
The Find method has an argument LookAt, which according to help:
"LookAt Optional Variant. Can be one of the following XlLookAt constants:
xlWhole or xlPart"
Does that work for you ?

Otherwise, maybe write you own FindEx method to give you more control.
Regular Expressions (RegEx)
http://visualbasic.about.com/od/usin...l/blregexa.htm

or Split(YourText," "), then serch the array.

NickHK

"Derrick Salmon" wrote in message
ups.com...
Hi All

I have cells in an excel spreadsheet with contents (employee short-form
initials) like [tv pm dsab sa] - this is the content of a single cell.
When such cells are scanned for contents equal to, say, 'ds' or 'sa' I
don't want to flag on 'dsab' (which contains both 'ds' and 'sa'), but
only on matches to 'ds' or to 'sa' as unique values.

I've tried using Find with what:="xx " i.e. using the space between
words as part of the search string, bu this fails on the last entry in
the cell (above, [ ... sa] has no trailing space in the cell content so
is not found

There has to be a better (real) way ...


cheers


Derrick