Compare Text Between 2 Cells (1 Viewer)

Peter Quill

Member
Local time
Today, 17:02
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
 

June7

AWF VIP
Local time
Today, 03:02
Joined
Mar 9, 2014
Messages
5,474
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.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:02
Joined
May 7, 2009
Messages
19,245
maybe ChatGPT can figure that out.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 12:02
Joined
Feb 19, 2013
Messages
16,616
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

Top Bottom