+ Reply to Thread
Results 1 to 10 of 10

extract 10 digit number only from text string

  1. #1
    Forum Contributor visha_1984's Avatar
    Join Date
    11-27-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2013
    Posts
    309

    extract 10 digit number only from text string

    Hi Friends

    I want to try extract 10 digit mobile number from text sting
    any formula to do it

    text is like

    Mr. Pradeep M. Pardeshi,Plot No.5, Gadkari Nagar,Opp. Ganesh Traders, Khadka Road,Bhusawal, Jalgaon - 425201-9021286428-pardeshi.pradeep007@gmail.com

    output :- 9021286428

    any help much appreciate
    Attached Files Attached Files
    Last edited by visha_1984; 02-05-2015 at 07:34 AM.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: extract 10 digit number only from text string

    is this section always in this format?

    - 425201-9021286428-

    dash space 6 digits dash ten digits dash ?

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by mehmetcik; 02-05-2015 at 10:28 AM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    07-16-2012
    Location
    Newcastle upon Tyne
    MS-Off Ver
    Excel 2010
    Posts
    69

    Re: extract 10 digit number only from text string

    This will extract the highest 10-digit number it can find in the cell...
    In B2 - Array entered (press Ctrl+Shift+Enter):

    =MAX(IFERROR(--MID(A2,ROW(INDEX($A:$A,1):INDEX($A:$A,LEN($A2)-9)),10),0))

    Copy B2 downward as far as required.
    Steve D. a.k.a. Stephen Dunn

  4. #4
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: extract 10 digit number only from text string

    Regular formula

    in B2 and copy down

    =TRIM(LEFT(SUBSTITUTE(SUBSTITUTE(TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",255)),225)),":-",""),"-",REPT(" ",255)),255))
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  5. #5
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,645

    Re: extract 10 digit number only from text string

    Shorter a bit:

    =MAX(IFERROR(INDEX(MID(A2,ROW(INDIRECT("1:"&LEN(A2))),10)+0,),""))

    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.
    Quang PT

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: extract 10 digit number only from text string

    Quote Originally Posted by stunn View Post
    =MAX(IFERROR(--MID(A2,ROW(INDEX($A:$A,1):INDEX($A:$A,LEN($A2)-9)),10),0))
    Quote Originally Posted by bebo021999 View Post
    =MAX(IFERROR(INDEX(MID(A2,ROW(INDIRECT("1:"&LEN(A2))),10)+0,),""))
    Of course, it should probably be mentioned that both of these solutions depend on there being no other numbers within the string which are greater than 10 digits long.

    In general, if this cannot be guaranteed, then you need something like:

    =MID(A2,MATCH(12,MMULT(ABS(ISNUMBER(0+MID(MID("ζ"&A2&"ζ",ROW(INDIRECT("1:"&LEN(A2)-10)),12),{1,2,3,4,5,6,7,8,9,10,11,12},1))-{1,0,0,0,0,0,0,0,0,0,0,1}),{1;1;1;1;1;1;1;1;1;1;1;1}),0),10)

    which, incidentally, does not require CSE, and would return correctly:

    1234123411

    from a string such as:

    ABC 1234123411 DEF 123412341234

    whereas the two previous set-ups would both incorrectly give:

    3412341234

    Regards
    Last edited by XOR LX; 02-05-2015 at 12:24 PM.
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  7. #7
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: extract 10 digit number only from text string

    A little bit shorter version of the one in my previous post.

    =LEFT(TRIM(RIGHT(SUBSTITUTE(SUBSTITUTE(A2,":-"," ")," ",REPT(" ",255)),225)),10)

  8. #8
    Registered User
    Join Date
    07-16-2012
    Location
    Newcastle upon Tyne
    MS-Off Ver
    Excel 2010
    Posts
    69

    Re: extract 10 digit number only from text string

    bebo021999 & XOR LX,

    I tend to avoid INDIRECT because of its volatile nature, and there was nothing in the spreadsheet to suggest that there would ever be numbers longer than 10 digits in the cells to be examined.

  9. #9
    Forum Contributor visha_1984's Avatar
    Join Date
    11-27-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2013
    Posts
    309

    Re: extract 10 digit number only from text string

    Thanks everybody

    All formula worked perfect, have a good day.

  10. #10
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: extract 10 digit number only from text string

    You're welcome and thank you for the feedback!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Extract Exact 6 Digit Number From String
    By tt388 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-11-2013, 12:51 PM
  2. [SOLVED] How to Extract A Number from String if Text within the String Equals XYZ
    By tyrsfury in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-15-2012, 03:30 PM
  3. Extract 9 digit number from string
    By Jbentley in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-16-2011, 07:02 AM
  4. [SOLVED] Extract 10 digit number from string
    By R. Choate in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 10-27-2005, 06:05 PM
  5. [SOLVED] Extract 2, 3, 4 or 5-digit number from string
    By Jim in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-07-2005, 10:22 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1