6

If cell A1 = abcd, cell B1 = abcdefg, then what formula to use in order to get the text difference efg?

6
  • What would you expect the answer to be if A1 = bcd and B1 = adefg ? – Lee Taylor Dec 12 '12 at 10:48
  • I expect nothing to happen (tested it of course in advance), because the string isn't present in the other string. @Lee: what would you expect? – Jacob Jan Tuinstra Dec 12 '12 at 11:04
  • @JacobJanTuinstra - I was trying to get the OP to suggest what he was trying to achieve. I don't it's completely clear what he's asking for. After all what does "text difference" mean? – Lee Taylor Dec 12 '12 at 12:26
  • @Lee, the OP wants to have "efg" aka the difference. – Jacob Jan Tuinstra Dec 12 '12 at 12:49
  • 3
    @JacobJanTuinstra Hmmm, so the text difference should be all the characters in B1 that are not in A1? So, with A1 = bcd and B1 = adefg this would be aefg? Do you not see the ambiguity? – Lee Taylor Dec 12 '12 at 13:04
12

By using the following formula, you can achieve just that:

=SUBSTITUTE(B1,A1,"")

Reference: SUBSTITUTE

1
  • 1
    so simple... :-) nice! ...but of course not directly extensible to differences in the middle or when you don't know which cell might have the extra "different" characters - thanks for what it's worth though. – Code Jockey Feb 16 '16 at 17:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.