Thread: Like Operator
View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Like Operator

I assume the OP can determine what is appropriate to his or her situation.

ActiveCell.Text appeared most appropriate to me in this instance. Dates
weren't an issue in the question and it wasn't offered as a turnkey solution
to all such tests. As long as we are going to imagine any conceivable
situation, if in regional settings the user set MM dd, yyyy as the short
date format, then using value would be problematic as well:

From the immediate window:
? activeCell.Value
Jun 24, 2004
? Instr(activecell.Value," ")
4

So value2 would need to be used in that case.

Thanks for your interest.

--
Regards,
Tom Ogilvy




"Harlan Grove" wrote in message
...
"Tom Ogilvy" wrote...
If instr(activecell.text," ") then
msgbox "Check cell contents"
exit sub
end if


Why .Text rather than .Value? Unexpected things could happen in some Date
and mixed Date/Time number formats. Suppose it's up to the OP whether

dates
appearing like '28 Jun 2004' but stored as 38166 would be considered
stopping criteria.

InStr(x, " ") is likely to be faster than x Like "* *", but a single
instance of either would take negligible time.