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>
 
Perhaps I'm totally missing the point here. Excuse me for that.
That being said, if 9 (or more) characters out of 12 characters match, the outcome should be TRUE. Is that correct? Or should ALL characters match?
What you mean by "Relative Position"? That the character should appear in the string no matter what position?

I created a another layout just to compare more easy. Would you please comment on this example and what should be your outcome?

* NOM = Number of characters that match.
CODEAccording to you123456789101112* NOMAccording to me
F0FXE98MUBQF
FALSEF0FXE98MUBQF
10TRUE
J0FXE98MJBQFFALSEJ0FXE98MJBQF
10TRUE
1ZP0XDJYKG5K
TRUE1ZP0XDJYKG5K
12TRUE
1ZP0XDJYKG5KTRUE1ZP0XDJYKG5K
12TRUE
1NW3FWG9CWKE
FALSE1NW3FWG9CWKE
11TRUE
1JW3FWG9CWKEFALSE1JW3FWG9CWKE
11TRUE
N5W4D9WXJKPB
FALSEN5W4D9WXJKPB
11TRUE
J5W4D9WXJKPBFALSEJ5W4D9WXJKPB
11TRUE
291SN1Y8V5AN
TRUE291SN1Y8V5AN
12TRUE
291SN1Y8V5ANTRUE291SN1Y8V5AN
12TRUE
F7M61Q0J5GEV
FALSEF7M61Q0J5GEV
11TRUE
J7M61Q0J5GEVFALSEJ7M61Q0J5GEV
11TRUE
F4Q1UX21YFG9
FALSEF4Q1UX21YFG9
11TRUE
J4Q1UX21YFG9FALSEJ4Q1UX21YFG9
11TRUE
R4XPNT40TDAS
FALSER4XPNT40TDAS
4FALSE
R4XPJJ14QTDAFALSER4XPJJ14QTDA
4FALSE
MEEM0MMEXYX9
FALSEMEEM0MMEXYX9
11TRUE
JEEM0MMEXYX9FALSEJEEM0MMEXYX9
11TRUE
FTHAAPMLN8JF
FALSEFTHAAPMLN8JF
2FALSE
THAAPMLN8JFFFALSETHAAPMLN8JFF
2FALSE

<tbody>
</tbody>
 
Last edited:
Upvote 0

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
You understanding is correct in the table above, what I ment by relative position is that below has 12 characters all in the string but they are completely in the wrong order, this must fail

ABC DEF GHI JKL

LKJ IHG FED CBA

But like the examples above

ABC DEF GHI JKL

ABC DEF GHI JJJ

This is acceptable as the 9 characters that match are in the same position.

I hope this helps
 
Upvote 0
But, in your very first post in this thread, you gave this pair as the final of your examples:

FTHAAPMLN8JF
THAAPMLN8JF


and indicated that it should be considered a match.

However, the second of these only has 11 characters; the first 12. And, depending how you define "relative position", it could quite easily be argued that only 1 character matches between those two strings, as here:

Position010203040506070809101112
String 1FTHAAPMLN8JF
String 2THAAPMLN8JF
MatchNNNYNNNNNNNN

<tbody>
</tbody>

Of course, you might counter that, in this case, we should compare 2nd string beginning with the 2nd character of the 1st string, viz:

Position010203040506070809101112
String 1FTHAAPMLN8JF
String 2
THAAPMLN8JF
Match?
YYYYYYYYYYY

<tbody>
</tbody>

but then isn't this just rather arbitrary (and also convenient)?

Regards
 
Upvote 0
Hi Rick, I must be doing something stupid this gives "me" a False for everyone.....
Did you commit the formula using CTRL+SHIFT+ENTER and not Enter by itself? However, I have to modify my formula because I forgot to test each value's length to make sure they are exactly 12 characters long. Here is my revised array-entered** formula...

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

**Commit this formula using CTRL+SHIFT+ENTER and not just Enter by itself
 
Upvote 0
I agree but the device that is outputting the codes cannot cope with the 2nd table so in this instance this will be a fail.

-- removed inline image ---
 
Upvote 0
Hi Rick this works, however if i paste in to multiple cells it always refers back to cell A1 B1, is there a easy way to paste this formula as I my sheet goes from A1 - A9500 approx and I dont want to have to press Ctrl +shift + Enter on every cell !!!
 
Upvote 0
Hi Rick this works, however if i paste in to multiple cells it always refers back to cell A1 B1, is there a easy way to paste this formula as I my sheet goes from A1 - A9500 approx and I dont want to have to press Ctrl +shift + Enter on every cell !!!
First of all, I need to modify the formula slightly (I forgot to make the row number in the ROW function call absolute so they don't change when copied). Here is the new formula...

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

Now, assuming you are putting the formula in Column C, select cell C1 and array-enter the formula (as described in my previous messages) into it. Next, type C1:C9500 into the Name Box (the field to the left of the Formula Bar) and hit the Enter key... this will select all the cell you want to put the formula into... then click the Fill button (Home tab, Editing panel) and select Down from the popup menu that appears... that should copy the formula you array-entered in cell C1 down through all the selected cells.
 
Upvote 0

Forum statistics

Threads
1,215,773
Messages
6,126,822
Members
449,341
Latest member
addman24

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