View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Comparing Cell Contents using a Case statement

if lcase(cell.Value) like "*apple*" then


from the immediate window:

ActiveCell.Value = "Johnny Appleseed"
? lcase(activecell.Value) Like "*apple*"
True
--
Regards,
Tom Ogilvy



"todd" wrote in message
...
I am writing a macro that will compare cell contents, using a case

statement.
Does a method exist where a comparison can be made on a portion of the

cell
contents? For example, I might want to act on a cell that contains the

word
"apple". The caveat is that "apple" is not the only thing in the cell
string. I tried to use "like" and "is", but received a compile error -
apparently "like" and "is" are not valid comparison operators. What else
could I try?