Find numbers that are 9 or 10 characters long in mixed string

Chrissy_M

New Member
Joined
May 16, 2024
Messages
20
Office Version
  1. 365
Platform
  1. Windows
I have a mixed variety of cell contents, whereby multiple number references appear.
I am looking for a formula to extract any numbers within a cell that is 9 or 10 characters long.
If the number begins with a zero, I would like the zeros to be included in the results.

Example in lines 2, and 3 below show additional numbers (2 and 1, respectively), I do not want any number/s that are not 9 or 10 characters long returned in the results.

For example, line 3 results I am trying to get would be: 0000065234

Appreciate any help with this one - thank you

The cat went 0000052489 out to play
The black dog 1000035687 slept under window number 2
The bird with 1 eye was stuck in it's cage 0000065234
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Where do you want the extracted data to go? Another Sheet? Another column on the same Sheet?
 
Upvote 0
Hello, how about:

Excel Formula:
=MAP(A1:A3,LAMBDA(x,
LET(
a,TEXTSPLIT(x," "),
b,(LEN(a)>=9)*(LEN(a)<=10)*ISNUMBER(--a),
FILTER(a,b=1,""))))
 
Upvote 0
To clarify, top row indicates columns, left column indicates rows.
I would like formula in column A to reference cells in column B, and return 9 or 10 character number strings only, ignoring other numerical references within the string.

Hope this helps clarify my original post - thanks

AB
10000052489 The cat went 0000052489 out to play
21000035687The black dog 1000035687 slept under window number 2
30000065234The bird with 1 eye was stuck in it's cage 0000065234
 
Upvote 0
Hello, how about:

Excel Formula:
=MAP(A1:A3,LAMBDA(x,
LET(
a,TEXTSPLIT(x," "),
b,(LEN(a)>=9)*(LEN(a)<=10)*ISNUMBER(--a),
FILTER(a,b=1,""))))
Hi there, I think we nearly got it. Can we adjust it to only return 10 character numbers only. ie. if the numbers are followed by a full stop, I do not want the full stop added to the results. Some of the 9 digit numbers have returned full stops as well and I do not want this included
 
Upvote 0
Hello, many thanks for the feedback. Indeed, I have not considered that option, the adjusted formula only extracts 10 digit numbers and should even work where the number is followed by either "." or ",":

Excel Formula:
=MAP(B1:B3,LAMBDA(x,
LET(
a,TEXTSPLIT(x,{" ",".",","}),
b,(LEN(a)=10)*(ISNUMBER(--a)),
FILTER(a,b=1,""))))

P. S. Is it possible that there are 2 or more 10-digit numbers in a single cell?
 
Upvote 0

Forum statistics

Threads
1,223,871
Messages
6,175,099
Members
452,612
Latest member
MESTeacher

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