View Single Post
 
Old 07-08-2011, 01:14 PM
Colin Legg's Avatar
Colin Legg Colin Legg is offline Windows 7 32bit Office 2010 32bit
Expert
 
Join Date: Jan 2011
Location: UK
Posts: 369
Colin Legg will become famous soon enough
Default

Is this comparision within a worksheet formula, or in VBA? I'll assume the former...

Excel has a few string functions which perform this sort of comparision, of which two prime candidates are SEARCH() and FIND(). FIND() is the case sensitive function of the pair, so will suit your needs perfectly. This formula returns the value in B1 if B1 is contained in A1; else it returns the value in A1.

=IF(ISNUMBER(FIND(B1,A1)),B1,A1)
__________________
Colin

RAD Excel Blog
Reply With Quote