Compare sentences in 2 cells and retrieve missing values

Rahu

New Member
Joined
Dec 15, 2022
Messages
2
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
Platform
  1. Windows
I have 2 cells containing sentences(out of which 1 is right answer and another is wrong). What I want is to find out is the missing words in the wrong answer when compared to right answer.
Example: Cell A1(Right Answer): We strongly recommend enabling push notifications on this device.
Cell B2(Wrong Answer): strongly enabling notifications device.

What I want the formula or VBA code to retrieve in cell C3 is [We recommend push on this].

Can anyone please help me with this. And also the delimters in the data are spaces only.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Is this what you want?

Book1
ABC
1We strongly recommend enabling push notifications on this devicerecommend enabling push notifications on this device 
2strongly recommend enabling push notifications on this deviceWe recommend push on this
3recommend enabling push notifications on this deviceWe recommend push on this
Sheet1
Cell Formulas
RangeFormula
C1:C3C1=IF(ISERROR(MATCH(B1,A:A,0)),"We recommend push on this","")
 
Upvote 0
Thanks for the reply.
What I am looking for is a code should automatically retrieve missing words when comparing A1 and B1. We should not feed anything like "We recommend push on this".
A1: aba abb abc abd
B1: aba abb abe abf
C1: abc abd
 
Upvote 0
What versions of Xl does this need to work on, you are showing 4 different versions in your profile.
 
Upvote 0
Thanks for the reply.
What I am looking for is a code should automatically retrieve missing words when comparing A1 and B1. We should not feed anything like "We recommend push on this".
A1: aba abb abc abd
B1: aba abb abe abf
C1: abc abd
See it:
Book1
ABC
1aba abb abc abdaba abb abe abfabc abd
2We strongly recommend enabling push notifications on this device.strongly enabling notifications device.We recommend push on this device.
Sheet1
Cell Formulas
RangeFormula
C1:C2C1=SUBSTITUTE(TRIM(SUBSTITUTE(CONCAT(IF(MID(" "&A1&" ",ROW(INDIRECT("1:"&LEN(A1)+1)),1)=" ",IF(ISERROR(SEARCH(MID(" "&A1&" ",ROW(INDIRECT("1:"&LEN(A1)+1)),FIND(" "," "&A1&",",ROW(INDIRECT("2:"&LEN(A1)+2)))-ROW(INDIRECT("1:"&LEN(A1)+1))+1)," "&B1&" ")),MID(" "&A1&" ",ROW(INDIRECT("1:"&LEN(A1)+1)),FIND(" "," "&A1&" ",ROW(INDIRECT("2:"&LEN(A1)+2)))-ROW(INDIRECT("1:"&LEN(A1)+1))+1),""),""))," "," "))," "," ")
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Last edited:
Upvote 0
Another option for 365
Fluff.xlsm
ABC
1
2We strongly recommend enabling push notifications on this device.recommend enabling push notifications on this device.We strongly
3We strongly recommend enabling push notifications on this device.strongly enabling notifications device.We recommend push on this
Lists
Cell Formulas
RangeFormula
C2:C3C2=LET(a,TEXTSPLIT(A2," "),TEXTJOIN(" ",,FILTER(a,ISNA(MATCH(a,TEXTSPLIT(B2," "),0)))))
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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