Extract text matching a number of criteria

ace_if

New Member
Joined
Oct 4, 2017
Messages
2
I have a column with each cell containing text with a reference which I need to extract, the reference is always 10 characters with first 2 being letters (either NL,LT or BE) followed by 5 numbers, followed by a "-" and 2 numbers at the end. The reference is not always in the same position in the string. Couple of examples below:

EXAMPLE 1

DIMOVA, ADRIANA
NONREF 4353647465464336
/OCMT/EUR60,71/ORD.BANK/DEUTDEDBMUC/ORD.CUST/DIMOVA, ADRIANA/PAY
.DET./RECHNUNGNR. NL76549-10 BUSINESS-ID 76549"


EXAMPLE 2

CLAUDIA ZINAYIDA
TFR+
BE75491-25 BEAUTIQUE CRISTINA FERNAN DES
CHARGE WAIVED

I'm looking for a formula which will pick up the string "NL76549-10" in example 1 and "BE75491-25" in example 2.
I've tried a formula along the lines of

IF(FIND("NL",A1,20)-FIND("-",A1,FIND("NL",A1,20))=-7,MID(A1,FIND("NL",A1,20),10),"CHECK")

and combining the iferror function search for BE and LT however I run into issues when there are multiple instances of "NL" or "BE" or "LT" in the string and the reference number is not always the first or the last to contain the string.

Any help will be greatly appreciated
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Try

=IF(ISNUMBER(SEARCH("* NL?????-?? *"," "&A1)),MID(A1,SEARCH("NL?????-??",A1),10),IF(ISNUMBER(SEARCH("* BE?????-?? *",A1)),MID(A1,SEARCH("BE?????-??",A1),10),IF(ISNUMBER(SEARCH("* LT?????-?? *",A1)),MID(A1,SEARCH("LT?????-??",A1),10),"NOT FOUND")))
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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