Cell contents - Percentage match?

JazzSP8

Well-known Member
Joined
Sep 30, 2005
Messages
1,233
Office Version
  1. 365
Platform
  1. Windows
Hey All

I'm after a method of comparing two cells and seeing how similar they are, preferably in a percentage format based on the words in the cell.

So;

A1 = "Apples" | B1 = "Apples" - The result would be 100%

A1 = "Apples" | B1 = "Banana" - The result would be 0%

A1 = "Apples Banana" | B1 = "Apples" - The result would be 50%

I'm thinking I might have to go the UDF route, but, thought I'd see if I'd overthought it first LOL

Thanks in advance for any help you can provide :)
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
What other scenarios might there be ?

A1 = "Apples Banana Plum" | B1 = "Apples Orange Grape"
Result = ?
 
Upvote 0
What other scenarios might there be ?

A1 = "Apples Banana Plum" | B1 = "Apples Orange Grape"
Result = ?

Good question.

It's the number of matching words I'm after compared to the whole, using your example I'd be looking for a result of 33%

One word of three matches.
 
Upvote 0
A UDF might be preferable, if only for maintainability. But if you are looking at whole words within the string, then this formula might work for you:

ABC
1ApplesApples100%
2ApplesBanana0%
3Apples BananaApples50%
4Apples Banana PlumApples Orange Grape33%
5Apples Orange GrapeApples Orange67%
6Apples Banana Cherry Grape TangerineBanana Tangerine40%
7ApplesGrapes Pear Apples100%
8AppleApples0%
9applesApples100%
10100%

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet5

Array Formulas
CellFormula
C1{=SUM(ISNUMBER(SEARCH(MID(" "&A1&" ",IF(MID(" "&A1&" ",ROW(INDIRECT("1:"&LEN(A1)+1)),1)=" ",ROW(INDIRECT("1:"&LEN(A1)+1)),NA()),FIND(" "," "&A1&" ",ROW(INDIRECT("2:"&LEN(A1)+2)))-ROW(INDIRECT("1:"&LEN(A1)+1))+1)," "&B1&" "))+0)/(LEN(TRIM(A1))-LEN(SUBSTITUTE(TRIM(A1)," ",""))+1)}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>
 
Upvote 0
Brilliant! That looks like it'll do the trick!

Many many thanks for that - Much appreciated :)
 
Upvote 0

Forum statistics

Threads
1,221,469
Messages
6,160,027
Members
451,611
Latest member
PattiButche

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top