Comparing cells

P

Paul

I would like to place a formula in a cell where it
compares two cells and displays the difference between the
two cells.

Example:

Cell 1 contains: Paul
Cell 2 contains: Pual
Cell 3 (formual cell) shows either au or ua - displaying
both would be great.

Thanks for your time,
Paul.
 
M

Mark Graesser

This isn't a very clean way to do this but it will work:

=IF(LEFT(A1,1)=LEFT(B1,1),"*",LEFT(A1,1))&IF(MID(A1,2,1)=MID(B1,2,1),"*",MID
(A1,2,1))&IF(MID(A1,3,1)=MID(B1,3,1),"*",MID(A1,3,1))&IF(MID(A1,4,1)=MID(B1,
4,1),"*",MID(A1,4,1))

The first IF statement uses the LEFT function to compare the first
characters and prints an * if they are the same, or the character from the
first word if they are different. The other IF statements use the MID
function to compare the second, third and forth characters.

You can replace the "*" with "" if your prefer a blank, but then Saul versus
Pall would return Su instead of S*u*

You can add as many additional IF statements as you require. Since the IF
statements aren't nested you will not run into the limitation of 7.

Good Luck,
Mark Graesser
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top