Find "****-***" in a text string

Grimm127

Board Regular
Joined
Aug 17, 2011
Messages
132
Hi All you Guru's,
I have a set of document numbers that are mixed in a with other wording in a cell.
I just want to pull from the text string the 7 digit combination with the dash in the middle.
Something that looks like this = 123-4567 or 552-7743. The doc number is set like that
However each text box will have a different set of numbers.
I was thinking of a find ***-**** to pull what I am looking for.

Any suggestions?

Thank you
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Using some sample data the other contributers posted, maybe try the following:

Book1
AB
2aaaaaaa 123-4567 mmmmmmmmmm123-4567
3111111111 552-7743 222222222222552-7743
4Something that looks like this = 123-4567123-4567
5or 552-7743. The doc number is set like that552-7743
6or aaa-aaaa 552-7743. The doc number is set like that552-7743
7or bbb-bbbb 552-7743. The doc number is set like that552-7743
8HELP DESK OVERAGES PROCUREMENT-NOV22-166-2022166-2022
9OwnBackup:Enhcd Sandbox Seed(Mar-22-Jan23)300-2022300-2022
10test 123-12Nothing Found
Sheet3
Cell Formulas
RangeFormula
B2:B10B2=MAP(A2:A10,LAMBDA(x,LET(y,MID(x,SEQUENCE(LEN(x)),8),@FILTER(y,(MID(y,4,1)="-")*(ISNUMBER(--SUBSTITUTE(y&9999,"-",,1)))*(LEN(y)=8),"Nothing Found"))))
Dynamic array formulas.
 
Upvote 0
Another option

Book1
AB
1aaaaaaa 123-4567 mmmmmmmmmm123-4567
2111111111 552-7743 222222222222552-7743
3Something that looks like this = 123-4567123-4567
4or 552-7743. The doc number is set like that552-7743
5or aaa-aaaa 552-7743. The doc number is set like that552-7743
6or bbb-bbbb 552-7743. The doc number is set like that552-7743
7HELP DESK OVERAGES PROCUREMENT-NOV22-166-2022166-2022
8OwnBackup:Enhcd Sandbox Seed(Mar-22-Jan23)300-2022300-2022
9test 123-12Nothing found
Sheet1
Cell Formulas
RangeFormula
B1:B9B1=LET(x,IFERROR(--MID(A1,UNIQUE(SEARCH("-",A1,SEQUENCE(LEN(A1))))-{3,-1},{3,4}),0),TEXTJOIN("-",,FILTER(x,MMULT((x>0)*(LEN(INDEX(x,,2))=4),{1;1}),"Nothing found")))
 
Upvote 0
Version 2022 (Build 14931.20724)

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
Another couple of worksheet formula options if the functions are available.

23 02 14.xlsm
ABC
1aaaaaaa 123-4567 mmmmmmmmmm123-4567123-4567
2111111111 552-7743 222222222222552-7743552-7743
3Something that looks like this = 123-4567123-4567123-4567
4or 552-7743. The doc number is set like that552-7743552-7743
5or aaa-aaaa 552-7743. The doc number is set like that552-7743552-7743
6or bbb-bbbb 552-7743. The doc number is set like that552-7743552-7743
7HELP DESK OVERAGES PROCUREMENT-NOV22-166-2022166-2022166-2022
8OwnBackup:Enhcd Sandbox Seed(Mar-22-Jan23)300-2022300-2022300-2022
9test 123-12 
Doc Num
Cell Formulas
RangeFormula
C1:C9C1=BYROW(A1:A9,LAMBDA(r,LET(t,"111-1111",c,MID(r,SEQUENCE(LEN(r)),1),MID(r,FIND(t,CONCAT(IF(ISNUMBER(c+0),1,c)," ",t)),8))))
B1:B9B1=LET(t,"111-1111",c,MID(A1,SEQUENCE(LEN(A1)),1),MID(A1,FIND(t,CONCAT(IF(ISNUMBER(c+0),1,c)," ",t)),8))
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,214,994
Messages
6,122,633
Members
449,092
Latest member
bsb1122

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