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)
|