+ Reply to Thread
Results 1 to 16 of 16

Formula to extract Registration Number (ABN) from text in a cell

  1. #1
    Registered User
    Join Date
    03-21-2014
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    9

    Formula to extract Registration Number (ABN) from text in a cell

    I need to extract the Australian Business Number (ABN) from company details entered as text in a single cell.

    An ABN is always 11 digits, the text as entered is inconsistently formatted sometimes the ABN will include spaces sometimes not, sometimes a group of 2 digits, then three groups of three; sometimes three groups of three, then a group of two digits last last.

    So basically the only thing that can be assumed is that it will be a text sequence of 11 digits, which may or may not include spaces, but will definitely not include other characters.

    The company details will also contain various numbers in different and inconsistent places, but its safe to assume the ABN will be the only sequence of 11 digits (+/- spaces)

    Can this be done with a formula?
    Attached Files Attached Files
    Last edited by &Roo; 01-15-2015 at 06:11 AM. Reason: add info & update example spreadsheet

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

    Re: Formula to extract Registration Number (ABN) from text in a cell

    Have you tried:

    =SUBSTITUTE(A1," ","")
    Quang PT

  3. #3
    Valued Forum Contributor AZ-XL's Avatar
    Join Date
    03-22-2013
    Location
    Azerbaijan, Baku
    MS-Off Ver
    Excel 2007
    Posts
    603

    Re: Formula to extract Registration Number (ABN) from text in a cell

    Please upload excel files with examples and desired result
    Appreciate the help? CLICK *

  4. #4
    Registered User
    Join Date
    12-23-2013
    Location
    Gurgaon
    MS-Off Ver
    Excel 2013
    Posts
    36

    Re: Formula to extract Registration Number (ABN) from text in a cell

    Hi &Roo,

    Please upload sample numbers so that I can work on it and help you get your desired result
    Maitray,

  5. #5
    Registered User
    Join Date
    08-29-2014
    Location
    India
    MS-Off Ver
    2007
    Posts
    5

    Re: Formula to extract Registration Number (ABN) from text in a cell

    Hi,

    try this formula:-=SUBSTITUTE(MID(B2,MIN(FIND({0,1,2,3,4,5,6,7,8,9},B2&"0,1,2,3,4,5,6,7,8,9")),LEN(B2))," ","")

    let me know it works or not.

    Thanks
    Anil

  6. #6
    Registered User
    Join Date
    05-10-2013
    Location
    Pomáz, Hungary
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Formula to extract Registration Number (ABN) from text in a cell

    Enter in B2 with Shift+Ctrl+Enter, not just Enter:

    =MID(SUBSTITUTE(A2," ",""),MATCH(TRUE,ISNUMBER(--MID(SUBSTITUTE(A2," ",""),ROW($1:$130),11)),0),11)+0

  7. #7
    Registered User
    Join Date
    03-21-2014
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Formula to extract Registration Number (ABN) from text in a cell

    Thanks for the suggestion - that works to get rid of spaces, but not the other details that I don't want. I might be able to use it as part of the answer but it's not enough on it's own.

  8. #8
    Registered User
    Join Date
    03-21-2014
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Formula to extract Registration Number (ABN) from text in a cell

    Sorry I could not get this formula to work.

  9. #9
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Formula to extract Registration Number (ABN) from text in a cell

    Hi,

    So what is it with Itsvan's array formula (apart from referencing D2 rather than A2), that is not working?
    It seems to give the right results for me. Remember it's an array formula entered with Ctrl-Shift-Enter
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  10. #10
    Registered User
    Join Date
    03-21-2014
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Formula to extract Registration Number (ABN) from text in a cell

    Quote Originally Posted by István Hirsch View Post
    Enter in B2 with Shift+Ctrl+Enter, not just Enter:

    =MID(SUBSTITUTE(A2," ",""),MATCH(TRUE,ISNUMBER(--MID(SUBSTITUTE(A2," ",""),ROW($1:$130),11)),0),11)+0
    Thanks István - that works beautifully!

  11. #11
    Registered User
    Join Date
    03-21-2014
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Formula to extract Registration Number (ABN) from text in a cell

    Quote Originally Posted by Richard Buttrey View Post
    Hi,

    So what is it with Itsvan's array formula (apart from referencing D2 rather than A2), that is not working?
    It seems to give the right results for me. Remember it's an array formula entered with Ctrl-Shift-Enter
    No that is me being a noob and not understanding how to reply propperly. It is Anil KMR's formula that I could not get to work :-/

  12. #12
    Registered User
    Join Date
    05-10-2013
    Location
    Pomáz, Hungary
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Formula to extract Registration Number (ABN) from text in a cell

    If you are going to insert new rows between the existing ones later, use this formula:

    =MID(SUBSTITUTE(A2," ",""),MATCH(TRUE,ISNUMBER(--MID(SUBSTITUTE(A2," ",""),ROW(INDIRECT("1:"&LEN(A2))),11)),0),11)+0

  13. #13
    Registered User
    Join Date
    03-21-2014
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Formula to extract Registration Number (ABN) from text in a cell

    Quote Originally Posted by István Hirsch View Post
    If you are going to insert new rows between the existing ones later, use this formula:

    =MID(SUBSTITUTE(A2," ",""),MATCH(TRUE,ISNUMBER(--MID(SUBSTITUTE(A2," ",""),ROW(INDIRECT("1:"&LEN(A2))),11)),0),11)+0
    Thanks again István, but when I tried the above formula I get an error message, and excel directs me to "0[" of the formula. I assume this also an array formula and requires activation with CSE.
    I don't know much about array formulas (and totally no clue what the double minus sign does) and don't understand this one well enough to correct it myself.

    Also I'm not sure why I need a different formula if I'm going to insert a row, I tried this to see what would happen and copied your original formula down from the above cell and had no apparent problems.

    What is the advantage of the amended formula that you've posted?

    Cheers.

  14. #14
    Registered User
    Join Date
    05-10-2013
    Location
    Pomáz, Hungary
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Formula to extract Registration Number (ABN) from text in a cell

    Thanks for the feedback.

    For me the formula in post #6 and post #12 gives the same result.

    im1.jpg

    im2 .jpg

    Comparison of the two formulas:

    While $1 increases to $130 in the part ROW($1:$130), the formula in post #6 checks if the string from the character positions 1-11, then 2-12, then 3-14 etc. up to 130-141 is a 11-digit long number or not, supposing that the whole length of the strings processed will not be longer than 130 characters.

    If two new cells are inserted then the formula in B2 (and similarly B5 and B6) changes to:

    MID(SUBSTITUTE(A2;" ";"");MATCH(TRUE;ISNUMBER(--MID(SUBSTITUTE(A2;" ";"");ROW($1:$132);11));0);11)+0

    This means that the former checking will be done up to the 132nd character position in spite of the fact that the actual string-lengths are around 50 character. As a length of 130 character seems enough to cover the possible length of the strings to be processed, going over 130 is needless.
    The second formula processes exactly as many characters as needed, that is, the length of the string, not more. Moreover it does not show the above-mentioned „shifting” effect.

  15. #15
    Registered User
    Join Date
    03-21-2014
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Formula to extract Registration Number (ABN) from text in a cell

    Quote Originally Posted by István Hirsch View Post
    Thanks for the feedback.

    For me the formula in post #6 and post #12 gives the same result.

    Attachment 370909

    Attachment 370910

    Comparison of the two formulas:

    While $1 increases to $130 in the part ROW($1:$130), the formula in post #6 checks if the string from the character positions 1-11, then 2-12, then 3-14 etc. up to 130-141 is a 11-digit long number or not, supposing that the whole length of the strings processed will not be longer than 130 characters.

    If two new cells are inserted then the formula in B2 (and similarly B5 and B6) changes to:

    MID(SUBSTITUTE(A2;" ";"");MATCH(TRUE;ISNUMBER(--MID(SUBSTITUTE(A2;" ";"");ROW($1:$132);11));0);11)+0

    This means that the former checking will be done up to the 132nd character position in spite of the fact that the actual string-lengths are around 50 character. As a length of 130 character seems enough to cover the possible length of the strings to be processed, going over 130 is needless.
    The second formula processes exactly as many characters as needed, that is, the length of the string, not more. Moreover it does not show the above-mentioned „shifting” effect.
    Hey thanks again, really appreciate teh help understanding the formula - I'd add more to your reputation, but umm excel forum wont let me, for now :-/

  16. #16
    Registered User
    Join Date
    05-10-2013
    Location
    Pomáz, Hungary
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Formula to extract Registration Number (ABN) from text in a cell

    No problem, thanks 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 number within text in a cell
    By YasserKhalil in forum Excel General
    Replies: 7
    Last Post: 10-29-2014, 02:12 AM
  2. extract number from text and number cell
    By south in forum Excel General
    Replies: 15
    Last Post: 08-23-2014, 03:28 AM
  3. [SOLVED] Need to find a formula to extract a number out of a cell that also has letters
    By Cassi in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-25-2013, 09:39 PM
  4. Excel Formula to Extract a Number from a Cell
    By housinganalyst in forum Excel General
    Replies: 4
    Last Post: 07-29-2011, 11:41 AM
  5. extract number and use in formula from text & numbers in cell
    By ivory_kitten in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-14-2006, 12:45 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