+ Reply to Thread
Results 1 to 4 of 4

Formula to determine a sequence of 6 numbers in a text

  1. #1
    Registered User
    Join Date
    09-23-2011
    Location
    Calcutta
    MS-Off Ver
    Excel 2007
    Posts
    26

    Formula to determine a sequence of 6 numbers in a text

    Hi,

    I have a column (say B) with addresses entered in the cells. Within these addresses there exists a postal code of 6 digits. (Something like 52 North Street, 234056 -NZ).

    I want to capture this string of 6 digits in a separate column (say C).

    The problem is that, the sequence of 6 digits can be present anywhere in the address, not necessarily at the end. And the addresses themselves are of varying lengths, so the conventional RIGHT()/MID() functions wont be applicable here.

    There exists only one such continuous string of 6 digits in the entire address. Is it possible to use a formula to identify this?

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Formula to determine a sequence of 6 numbers in a text

    will there always be a comma , before the numbers?

    can you supply a few more examples?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Formula to determine a sequence of 6 numbers in a text

    Here's what I tried... not sure if it is something you can work with:

    1. Copy values from column B (assume b2:b10 for this example) to column A of a blank sheet.
    2. Run a 'Text-to-Columns' for the copied column, using a SPACE as the delimiter. This should spread the address across 5 or 6 cells.
    3. If the first row is A2, then in say, J2, put this formula: =INDEX(A2:I2,1,MATCH(99^99,A2:I2,1)) and fill down

    That should give you the postal codes.

    - Moo

  4. #4
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Formula to determine a sequence of 6 numbers in a text

    Actually, since you said the Postal Code can be anywhere in the cell, my previous formula would only return the correct result if the Postal Code is the last numeric value in the row after performing the Text-to-Columns. If the address number comes after the Postal Code, it would return the address number.

    Try this formula instead: =MAXA(A2:I2)

    or, if that doesn't work:

    An ARRAY formula (entered with Ctrl + Shift + Enter) then filled down:
    =INDEX(MAX(IF(ISNUMBER(A2:I2),A2:I2)),1)

    - Moo
    Last edited by Moo the Dog; 01-31-2013 at 03:26 AM. Reason: Added MAXA function.. rough night

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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