A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
For example:
=LET(c, TRIM(MID(A1, SEQUENCE(LEN(A1)-8), 9)), XLOOKUP(1, ISNUMBER(--c)*(LEN(c)=9), c))
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I want to extract 9 digit numerical value from a sentence,
Sample : S.No. 787324320, Key No. WRUU7CXR2
Sentence contains multiple spaces and sometimes no text.
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Answer accepted by question author
For example:
=LET(c, TRIM(MID(A1, SEQUENCE(LEN(A1)-8), 9)), XLOOKUP(1, ISNUMBER(--c)*(LEN(c)=9), c))
Dear Ashu3639,
Thanks for visiting Microsoft Community. I am happy to help you.
I understand that you want to extract numbers from a sentence in Excel.
You can use a dynamic array formula to extract all the numbers. Assuming the sentence is in cell A1, you can use the following formula:
=TEXTJOIN(", ", TRUE, IF(ISNUMBER(--MID(A1, ROW(INDIRECT("1:" & LEN(A1))), 1)), MID(A1, ROW(INDIRECT("1:" & LEN(A1))), 1), ""))
Step:
Best regards
Miyeon.S - MSFT |Microsoft Community Support Specialist
If somebody is looking for REGEX solution (the person needs to be on Insider Beta Channel), here is the solution
=REGEXEXTRACT(A2,"\b\d{9}\b|$")
Dear Ashu3639,
It's been a long time since I've heard back from you.
Has your problem been resolved? Please let me know if the formula I provided works.
Looking forward to your reply.
Miyeon.S - MSFT |Microsoft Community Support Specialist