Matching a partial string

steedy

New Member
Joined
Jun 19, 2015
Messages
8
Hi,

First time here, I hope somebody can help me. I have 2 Columns, in Column A I have a string that is 12 characters in length (fixed), in column B I could have exactly the same string, I need to make sure that A2 string = B2, A3 =B3 etc..... if I use the exact function this replies with a true or false answer which is great. However what i need is a true or false answer if 9 or more of the characters match, in the example below the 1st and last strings obviousley fail with the Exact function however I need them to pass as >9 match.

Any examples are greatfully received.

F0FXE98MUBQF
J0FXE98MJBQFFALSE
1ZP0XDJYKG5K1ZP0XDJYKG5KTRUE
GV7LRZKJGCY3GV7LRZKJGCY3TRUE
XBLD06NNNTDSXBLD06NNNTDSTRUE
G9LF2Y4KP49BG9LF2Y4KP49BTRUE
VGLE5JYKXFVMVGLE5JYKXFVMTRUE
291SN1Y8V5AN291SN1Y8V5ANTRUE
CY97EBEE46TZCY97EBEE46TZTRUE
NFXH3KSQC4UENFXH3KSQC4UETRUE
S0VM75RDELARS0VM75RDELARTRUE
QZL4H7GNH94AQZL4H7GNH94ATRUE
CMRN1YSJQT2ZCMRN1YSJQT2ZTRUE
FTHAAPMLN8JF
THAAPMLN8JFFALSE

<colgroup><col span="2"><col></colgroup><tbody>
</tbody>

<tbody>
</tbody>
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi.

Just to clarify: you don't mean that 9 or more characters have to match and also occupy the same position within the string, or even the same relative position to each other? If this was the case, your last example would not pass the test.

It would also mean that:

ABCDEFGHIJ

and

IEADFBGCJX

would be considered a match.

Can you just confirm this?

Regards
 
Upvote 0
Looking at examples he gave, I think that's exactly what he means.

Perhaps, but then they wouldn't be much of a match, would they?

And if my assumption was false, then we might be getting into the murky area of "fuzzy matching", unless of course the OP can come up with a more rigorous definition of what constitutes 9 or more characters "matching" for a given pair of strings.

Regards
 
Upvote 0
Thanks for the replies so far, the characters would not be mixed up as per the
ABCDEFGHIJ

and

IEADFBGCJX


so relative position would be the same unless the 1st character was missed and then the whole string would shift by 1 place, in this instance if it is to complicated it doesnt matter, so lets say the string is always 12 characters long and 9 out of the 12 must match and have the same relative position. Is there a way to do this ??
 
Upvote 0
So can you give some more varied examples together with your expected results, just so it's clear?

Regards
 
Upvote 0
Hi, so I've looked at this a bit more and think for ease we should say both strings should contain 12 characters, if 9 out of the 12 have the same relative position then it gives a true response. Here are some example codes.

Using the Exact function this has highlighted 3 strings that give a False but actually should return a True

F0FXE98MUBQF
J0FXE98MJBQF
FALSE
1ZP0XDJYKG5K1ZP0XDJYKG5K
TRUE
GV7LRZKJGCY3GV7LRZKJGCY3TRUE
VGLE5JYKXFVMVGLE5JYKXFVMTRUE
291SN1Y8V5AN291SN1Y8V5ANTRUE
CY97EBEE46TZCY97EBEE46TZTRUE
NFXH3KSQC4UENFXH3KSQC4UETRUE
S0VM75RDELARS0VM75RDELARTRUE
QZL4H7GNH94AQZL4H7GNH94ATRUE
CMRN1YSJQT2ZCMRN1YSJQT2ZTRUE
V9S9MFKAW02DV9S9MFKAW02DTRUE
KCEARLJJ6J21KCEARLJJ6J21TRUE
L48ZT6B5DB79L48ZT6B5DB79TRUE
KYBERTFDGD4XKYBERTFDGD4XTRUE
B1C6LXY2Z6S8B1C6LXY2Z6S8TRUE
0VNN86R29C8J0VNN86R29C8JTRUE
A7BMKT8YPN0ZA7BMKT8YPN0ZTRUE
1NW3FWG9CWKE1JW3FWG9CWKE
FALSE
5C5DKA1CJP5E5C5DKA1CJP5ETRUE
A9CDNG73TPWCA9CDNG73TPWCTRUE
39X3R6KB82AT39X3R6KB82ATTRUE
35L9H4SLZYSD35L9H4SLZYSDTRUE
N5W4D9WXJKPBJ5W4D9WXJKPB
FALSE

<colgroup><col span="3"></colgroup><tbody>
</tbody>



More FALSE examples, the one highlighted in RED really is false

F7M61Q0J5GEV
J7M61Q0J5GEV
FALSE
F4Q1UX21YFG9J4Q1UX21YFG9
FALSE
R4XPNT40TDAS
R4XPJJ14QTDAFALSE
MEEM0MMEXYX9JEEM0MMEXYX9
FALSE
HC6KPTZ27K8VJC6KPTZ27K8V
FALSE
E8ZLG3GRRHWCJ8ZLG3GRRHWCFALSE
Z8TEBCKMMU44J8TEBCKMMU44FALSE
R5YFTW2RWZECP5YFTW2RWZECFALSE
E0UY5TC4HDFLJ0UY5TC4HDFLFALSE
GZNB6YYK6N0RZJJB6YYK6N0RFALSE
H8FS8PJJUKVHJ8FS8PJJUKVHFALSE
45ESU9SKTZ3F45ESJ9SKTZ3FFALSE
HL96YNXFG8L2JL96YNXFG8L2FALSE
7U28Y2KYCPUY4U28Y2KYCPUYFALSE
DULDANPCW4B6DJLDANPCW4B6FALSE
U6DH0ADP2622J6DH0ADP2622FALSE
R83PNV3D9EQ5P83PNV3D9EQ5FALSE
H6MXVN638PWRJ6MXVN638PWRFALSE
XBWKJY9XRE7MKBWKJY9XRE7MFALSE
T5J4XX317F4DJ5J4XX317F4DFALSE
KU4EFDAM0HF3KD4EFDAM0HF3FALSE
UXENVWQ0X0Z3JXENVWQ0X0Z3FALSE
VCZJNXNTTXN5WCZJNXNTTXN5FALSE
H45EE87DNBXDJ45EE87DNBXD
FALSE
N2GVRMDSSAZ2
J2GVRMDSSAZ2
FALSE

<colgroup><col span="3"></colgroup><tbody>
</tbody>

A8KPX8Y1NMVV
A8KPX8K1TNMV
FALSE

<tbody>
</tbody>
 
Upvote 0
..if 9 out of the 12 have the same relative position then it gives a true response.
I must be reading something wrong here, but based on what you say above, I think every one of your examples are TRUE. Here is the array-entered** formula I used to get those results...

=SUM(0+(MID(A1,ROW(1:12),1)=MID(B1,ROW(1:12),1)))>=9

**Commit this formula using CTRL+SHIFT+ENTER and not just Enter by itself
 
Upvote 0

Forum statistics

Threads
1,215,110
Messages
6,123,138
Members
449,098
Latest member
Doanvanhieu

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