Compare Text Between 2 Cells

Peter Quill

Member
Local time
Today, 23:29
Joined
Apr 13, 2023
Messages
30
Hello,

Is there any way to compare text between 2 cells by ignoring if they are upper/lower case, punctuation, not in the same order, minimum 2 words same is okay. Please, see the below image. Thank you.

sample.JPG


Regards,
Peter
 
VBA is not case sensitive by default so that is covered. Otherwise, probably need code that parses the strings into distinct word components and compare word by word by looping arrays or collections. Removing all possible punctuation is a complication.

I won't be able to do any coding for a few days. Maybe someone else will jump in.
 
maybe ChatGPT can figure that out.
 
something like this aircode

Code:
function matchtext(strX as string, strY as string) as integer
'returns number of matches
dim a() as string
dim b() as string
dim i as integer
dim j as integer

if ubound(split(replace(strX,",",""))," "))>=ubound(split(replace(strY,",","")), " ")) then 'extend replace to other punctuation as required
    a=split(replace(strX,",",""))," ")
    b=split(replace(strY,",",""))," ")
else
    a=split(replace(strY,",",""))," ")
    b=split(replace(strX,",",""))," ")
end if

for i=0 to ubound(a)-1
    for j=0 to ubound(b)-1
         matchtext=matchtext-(a(i)=b(j))
    next j
next i

end function

you then need to decide what this number means in terms of a match. which is not clear from your example - for example is TV required to match to Television, is 14inch the same as 14 inch? What about typo's? - Your example is saying you should match 'Recorder' to Recoeder'
 
Last edited:

Users who are viewing this thread

Back
Top Bottom