Match value which is a part of a whole value

RAJESH1960

Banned for repeated rules violations
Joined
Mar 26, 2020
Messages
2,313
Office Version
  1. 2019
Platform
  1. Windows
Hello formula experts
I have a very challenging formula to write and I need your expertise to write it.
All the entries in this sheet are actually matched. Since the invoice numbers in tally rows is a part of the invoice number of Portal row, which happens in more than 90% of the cases, the formula is showing an invoice No. Mismatch in column K. I am not sure whether it is even possible to match a part of the Invoice number with another invoice number, but I want to give it a try. Formula to be something like this....
Search for the value in a cell of Tally row in Portal row whether it is in the beginning, in the middle or at the end of the value but in one sequences than treat it as a match. Can anyone help me to write this formula in column J and get the result as Matched.?

Get part of Invoice nu to match.xlsm
ABCDEFGHIJK
1LineAs PerGSTINNameInvoice No.DateIGSTCGSTSGSTRemarksInvoice No. Mismatch
25PORTAL06AAVPK7054P1ZT670200210200001326-05-2022MATCHEDInvoice No. Mismatch
36TALLY06AAVPK7054P1ZT1327-05-2022MATCHEDInvoice No. Mismatch
47PORTAL06AAVPK7054P1ZTG/36403-05-2022MATCHEDInvoice No. Mismatch
58TALLY06AAVPK7054P1ZT36404-05-2022MATCHEDInvoice No. Mismatch
61PORTAL06AARPP9088L1ZM000220/2022-2320-06-2022MATCHEDInvoice No. Mismatch
72TALLY06AARPP9088L1ZM22020-06-2022MATCHEDInvoice No. Mismatch
89PORTAL29AAACP0165G1ZLM22043000340171030-04-2022MATCHEDInvoice No. Mismatch
910TALLY29AAACP0165G1ZL340171030-04-2022MATCHEDInvoice No. Mismatch
1013PORTAL29AAACS9735K1ZRGST-186-2022-2329-07-2022MATCHEDInvoice No. Mismatch
1114TALLY29AAACS9735K1ZR18629-07-2022MATCHEDInvoice No. Mismatch
1215TALLY29AAACS9735K1ZR75614-05-2022MATCHEDInvoice No. Mismatch
1316PORTAL29AAACS9735K1ZR756/22-2314-05-2022MATCHEDInvoice No. Mismatch
1423PORTAL29AAACS9735K1ZRPNP/I/19928-05-2022MATCHEDInvoice No. Mismatch
1524TALLY29AAACS9735K1ZR19928-05-2022MATCHEDInvoice No. Mismatch
1629PORTAL29AAACS9735K1ZR925/22-2325-05-2022MATCHEDInvoice No. Mismatch
1730PORTAL29AAACS9735K1ZR1080/22-2302-06-2022MATCHEDInvoice No. Mismatch
1832TALLY29AAACS9735K1ZR92525-05-2022MATCHEDInvoice No. Mismatch
1933TALLY29AAACS9735K1ZR108002-06-2022MATCHEDInvoice No. Mismatch
2017PORTAL29AAACS9735K1ZRTAX/02432/22-2321-05-2022MATCHEDInvoice No. Mismatch
2118TALLY29AAACS9735K1ZR243222-05-2022MATCHEDInvoice No. Mismatch
2221PORTAL29AAACS9735K1ZR173/22-2312-04-2022MATCHEDInvoice No. Mismatch
2322TALLY29AAACS9735K1ZR17313-04-2022MATCHEDInvoice No. Mismatch
2431PORTAL29AAACS9735K1ZR1434/22-2322-06-2022MATCHEDInvoice No. Mismatch
2534TALLY29AAACS9735K1ZR143423-06-2022MATCHEDInvoice No. Mismatch
263PORTAL06AARPP9088L1ZMR-4/2022-2304-07-2022MATCHEDInvoice No. Mismatch
274TALLY06AARPP9088L1ZM2304-07-2022MATCHEDInvoice No. Mismatch
2811PORTAL29AAACS9735K1ZR1468/22-2324-06-2022MATCHEDInvoice No. Mismatch
2912TALLY29AAACS9735K1ZR146824-06-2022MATCHEDInvoice No. Mismatch
3019PORTAL29AAACS9735K1ZR264/22-2318-04-2022MATCHEDInvoice No. Mismatch
3120TALLY29AAACS9735K1ZR26418-04-2022MATCHEDInvoice No. Mismatch
3225PORTAL29AAACS9735K1ZR808/22-2318-05-2022MATCHEDInvoice No. Mismatch
3326TALLY29AAACS9735K1ZR80818-05-2022MATCHEDInvoice No. Mismatch
3427PORTAL29AAACS9735K1ZR1322/22-2316-06-2022MATCHEDInvoice No. Mismatch
3528TALLY29AAACS9735K1ZR132216-06-2022MATCHEDInvoice No. Mismatch
Matched
Cell Formulas
RangeFormula
K2:K35K2=IF(COUNTIFS($B$2:$B$20000,IF($B2="PORTAL","TALLY","PORTAL"),$C$2:$C$20000,$C2,$E$2:$E$20000,$E2)>0,"MATCHED","Invoice No. Mismatch")
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
How about this? (This assumes that the one MISMATCH is actually a mismatch . . . that you made a typo with that one. It doesn't follow the general "pattern" either. And its invoice number should be 4.) And I made the assumption that with invoice number's like "6702002102000013" (without any "/" and "-" and any letters), that the invoice number begins if after at least 3 consecutive 0's. And that it begins with a digit other than 0. (And the orange helper columns calculate these types of invoice no.'s and the green calculates all other types.)

And, although I could put this in one formula, since the LET function is not in Office 2019, I don't think that would be a good idea!
Blank.xlsb
ABCDEFGHIJKLMNOPQRST
1LineAs PerGSTINNameInvoice No.DateIGSTCGSTSGSTRemarks/-
21PORTAL06AARPP9088L1ZM000220/2022-2320-06-2022MATCHED with TALLY on Line 2 71213220/2022-2347220220
32TALLY06AARPP9088L1ZM22020-06-2022  0000 13220 
43PORTAL06AARPP9088L1ZMR-4/2022-2304-07-2022NOT MATCHED!Invoice No. Mismatch: 44200 3444
54TALLY06AARPP9088L1ZM2304-07-2022  0000 1223 
65PORTAL06AAVPK7054P1ZT670200210200001326-05-2022MATCHED with TALLY on Line 6 0011413116670200210200001313
76TALLY06AAVPK7054P1ZT1327-05-2022  0000 1213 
87PORTAL06AAVPK7054P1ZTG/36403-05-2022MATCHED with TALLY on Line 8 2000 35364364
98TALLY06AAVPK7054P1ZT36404-05-2022  0000 13364 
109PORTAL29AAACP0165G1ZLM22043000340171030-04-2022MATCHED with TALLY on Line 10 007334017102162204300034017103401710
1110TALLY29AAACP0165G1ZL340171030-04-2022  0000 173401710 
1211PORTAL29AAACS9735K1ZR1468/22-2324-06-2022MATCHED with TALLY on Line 12 5800 1514681468
1312TALLY29AAACS9735K1ZR146824-06-2022  0000 141468 
1413PORTAL29AAACS9735K1ZRGST-186-2022-2329-07-2022MATCHED with TALLY on Line 14 0400 58186186
1514TALLY29AAACS9735K1ZR18629-07-2022  0000 13186 
1615TALLY29AAACS9735K1ZR75614-05-2022  0000 13756 
1716PORTAL29AAACS9735K1ZR756/22-2314-05-2022MATCHED with TALLY on Line 15 4700 14756756
1817PORTAL29AAACS9735K1ZRTAX/02432/22-2321-05-2022MATCHED with TALLY on Line 18 41300 61024322432
1918TALLY29AAACS9735K1ZR243222-05-2022  0000 142432 
2019PORTAL29AAACS9735K1ZR264/22-2318-04-2022MATCHED with TALLY on Line 20 4700 14264264
2120TALLY29AAACS9735K1ZR26418-04-2022  0000 13264 
2221PORTAL29AAACS9735K1ZR173/22-2312-04-2022MATCHED with TALLY on Line 22 4700 14173173
2322TALLY29AAACS9735K1ZR17313-04-2022  0000 13173 
2423PORTAL29AAACS9735K1ZRPNP/I/19928-05-2022MATCHED with TALLY on Line 24 4000 79199199
2524TALLY29AAACS9735K1ZR19928-05-2022  0000 13199 
2625PORTAL29AAACS9735K1ZR808/22-2318-05-2022MATCHED with TALLY on Line 26 4700 14808808
2726TALLY29AAACS9735K1ZR80818-05-2022  0000 13808 
2827PORTAL29AAACS9735K1ZR1322/22-2316-06-2022MATCHED with TALLY on Line 28 5800 1513221322
2928TALLY29AAACS9735K1ZR132216-06-2022  0000 141322 
3029PORTAL29AAACS9735K1ZR925/22-2325-05-2022MATCHED with TALLY on Line 32 4700 14925925
3130PORTAL29AAACS9735K1ZR1080/22-2302-06-2022MATCHED with TALLY on Line 33 5800 1510801080
3231PORTAL29AAACS9735K1ZR1434/22-2322-06-2022MATCHED with TALLY on Line 34 5800 1514341434
3332TALLY29AAACS9735K1ZR92525-05-2022  0000 13925 
3433TALLY29AAACS9735K1ZR108002-06-2022  0000 141080 
3534TALLY29AAACS9735K1ZR143423-06-2022  0000 141434 
Sheet1
Cell Formulas
RangeFormula
J2:J35J2=IF(IFERROR(MATCH(T2,E:E,0),-1)<>-1,"MATCHED with TALLY on Line "&INDEX(A:A,MATCH(T2,E:E,0),1),IF(B2="PORTAL","NOT MATCHED!",""))
K2:K35K2=IF(AND(B2="PORTAL",J2="NOT MATCHED!"),"Invoice No. Mismatch: "&T2,"")
L2:L35L2=IFERROR(SEARCH("/",E2),0)
M2:M35M2=IFERROR(SEARCH("-",E2),0)
N2:N35N2=MAX(IFERROR(SEARCH(REPT("0",SEQUENCE(1,LEN(E2),3)),E2,1),0))
O2:O35O2=MAX(IF(IFERROR(SEARCH(REPT("0",SEQUENCE(1,LEN(E2),3)),E2,1),0)<>0,LEN(REPT("0",SEQUENCE(1,LEN(E2),3))),0))
P2:P35P2=IFERROR(MID(E2,N2+O2,LEN(E2)),"")
Q2:Q35Q2=MIN(IF(IFERROR(IF(VALUE(MID(E2,SEQUENCE(1,LEN(E2),1),1))>0,VALUE(MID(E2,SEQUENCE(1,LEN(E2),1),1)),-1),-1)>-1,SEQUENCE(1,LEN(E2),1),LEN(E2)))
R2:R35R2=MIN(IFERROR(Q2+VALUE(IFERROR("|"&VALUE(MID(E2,SEQUENCE(1,LEN(E2),Q2+1),1)),SEQUENCE(1,LEN(E2),1))),LEN(E2)))
S2:S35S2=IF(IFERROR(VALUE(RIGHT(MID(E2,Q2,R2-Q2+1),1)),-1)=-1,LEFT(MID(E2,Q2,R2-Q2+1),LEN(MID(E2,Q2,R2-Q2+1))-1),MID(E2,Q2,R2-Q2+1))
T2:T35T2=IF(AND(L2=0,M2=0),P2,S2)
 
Upvote 0
Solution
Wow!! This was unexpected. You have been busy with the query and must have spent a lot of time trying to solve this. Thank you very much cmowla.:)
To be frank with you, it is very complicated and I didn't understand any part of it as it is beyond my capacity to understand it. But I will go through it and try to understand and learn something new and interesting.
I was just expecting a formula to enter in the remarks column and get all the rows as Matched.
Can you please the sheet where you have entered various formulas.? I don't see an option to copy or download it.
 
Upvote 0
You have been busy with the query and must have spent a lot of time trying to solve this.
I just spent about 2 hours (tops). I never did something like this before, to be honest.

Can you please the sheet where you have entered various formulas.? I don't see an option to copy or download it.
Just copy the formulas (one at a time) that are listed in the table Cell Formulas into the cell address in bold font (in your sheet). Once you have done that, carry (drag) all formulas down.

And, you're quite welcome!
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,191
Members
452,616
Latest member
intern444

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