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

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
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
ApplesApples
ApplesBanana
Apples BananaApples
Apples Banana PlumApples Orange Grape
Apples Orange GrapeApples Orange
Apples Banana Cherry Grape TangerineBanana Tangerine
ApplesGrapes Pear Apples
AppleApples
applesApples

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

[TD="align: right"]100%[/TD]

[TD="align: center"]2[/TD]

[TD="align: right"]0%[/TD]

[TD="align: center"]3[/TD]

[TD="align: right"]50%[/TD]

[TD="align: center"]4[/TD]

[TD="align: right"]33%[/TD]

[TD="align: center"]5[/TD]

[TD="align: right"]67%[/TD]

[TD="align: center"]6[/TD]

[TD="align: right"]40%[/TD]

[TD="align: center"]7[/TD]

[TD="align: right"]100%[/TD]

[TD="align: center"]8[/TD]

[TD="align: right"]0%[/TD]

[TD="align: center"]9[/TD]

[TD="align: right"]100%[/TD]

[TD="align: center"]10[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]100%[/TD]

</tbody>
Sheet5

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Array Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]C1[/TH]
[TD="align: left"]{=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)}[/TD]
[/TR]
</tbody>[/TABLE]
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Brilliant! That looks like it'll do the trick!

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

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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