+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 20

Thread: Extract number from text field

  1. #1
    Registered User
    Join Date
    06-16-2011
    Location
    hyderabad
    MS-Off Ver
    Excel 2003
    Posts
    30

    Extract number from text field

    i have list of address of customers which may or maynot contains zip code.

    eg:" C/O Ridhi Sidhi(Ganesham), 10 11, Basement Shardul Market, In Front Of Sbbj Bank, DT Jhunjhunu, PIN 333001

    " ..... i want a formula to extract 6 digit zipcode wherever it is in the address field

    it should extract just 6 digit number from all zip code

    thanks in advance for your help

  2. #2
    Valued Forum Contributor tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    USA
    MS-Off Ver
    Excel 2003 - 2007
    Posts
    2,342

    Re: Extract number from text field

    sailesh9630,

    If, like in your example, the zip code is always the last 6 characters of the address, you can use the following formula (assumes you have a header and the addresses start in A2:
    =RIGHT(A2,6)*1

    Then copy down.

    Hope that helps,
    ~tigeravatar

  3. #3
    Registered User
    Join Date
    06-16-2011
    Location
    hyderabad
    MS-Off Ver
    Excel 2003
    Posts
    30

    Re: Extract number from text field

    its working great but there is an error sometimes....

    like by mistake when in address its
    eg: J 904, Reliance Township, Near Nandipark Society, Piplod, Dist Surat 395007.

    after zip its fullstop .... its not working for it

    please help me
    Last edited by romperstomper; 06-17-2011 at 09:08 AM.

  4. #4
    Registered User
    Join Date
    06-16-2011
    Location
    hyderabad
    MS-Off Ver
    Excel 2003
    Posts
    30

    Re: Extract number from text field

    and its not compulsory that in data zip code is at end........
    it may be in middle of address.....

    if customers send address with error zip of 7 digit then it should not show any result

    is there a possibility.

  5. #5
    Valued Forum Contributor tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    USA
    MS-Off Ver
    Excel 2003 - 2007
    Posts
    2,342

    Re: Extract number from text field

    sailesh9630,

    Can you post a sample workbook so we can get a better idea of how to help you?

    ~tigeravatar

  6. #6
    Registered User
    Join Date
    06-16-2011
    Location
    hyderabad
    MS-Off Ver
    Excel 2003
    Posts
    30

    Re: Extract number from text field

    Quote Originally Posted by tigeravatar View Post
    sailesh9630,

    Can you post a sample workbook so we can get a better idea of how to help you?

    ~tigeravatar
    attaching file
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    06-16-2011
    Location
    hyderabad
    MS-Off Ver
    Excel 2003
    Posts
    30

    Re: Extract number from text field

    Quote Originally Posted by sailesh9630 View Post
    attaching file
    can you give your any chat account id so we can chat ...

    i will be thankful for your help....

  8. #8
    Valued Forum Contributor tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    USA
    MS-Off Ver
    Excel 2003 - 2007
    Posts
    2,342

    Re: Extract number from text field

    sailesh9630,

    Because of how your data is setup, I created an addin to introduce a new formula. Here is the link for the GETZIP_Formula addin.

    Download the addin and save it in the following folder:
    C:\Documents and Settings\%username%\Application Data\Microsoft\AddIns

    Then enable the add-in in Excel 2007/2010 by clicking on the office button -> Excel Options -> Add-ins -> Go -> and check "GETZIP_Formula"

    Then you will be able to type in cell D2:
    =IF(GETZIP(C2)=0,"",GETZIP(C2))

    and copy down.

    That formula has the following function:
    Public Function GETZIP(strAddress As String) As Double
        
        Dim AddressPart() As String: AddressPart = Split(strAddress, " ")
        Dim PartIndex As Long, SearchIndex As Long
        For PartIndex = 0 To UBound(AddressPart)
            If Len(AddressPart(PartIndex)) = 6 _
            And IsNumeric(AddressPart(PartIndex)) Then
                GETZIP = AddressPart(PartIndex)
                Exit Function
            ElseIf Len(AddressPart(PartIndex)) > 6 Then
                For SearchIndex = 1 To Len(AddressPart(PartIndex))
                    If Not IsNumeric(Mid(AddressPart(PartIndex), SearchIndex, 1)) Then
                        AddressPart(PartIndex) = Replace(AddressPart(PartIndex), Mid(AddressPart(PartIndex), SearchIndex, 1), vbNullString)
                    End If
                Next SearchIndex
                If Len(AddressPart(PartIndex)) = 6 _
                And IsNumeric(AddressPart(PartIndex)) Then
                    GETZIP = AddressPart(PartIndex)
                    Exit Function
                End If
            End If
        Next PartIndex
        
    End Function


    Hope that helps,
    ~tigeravatar

  9. #9
    Registered User
    Join Date
    06-16-2011
    Location
    hyderabad
    MS-Off Ver
    Excel 2003
    Posts
    30

    Re: Extract number from text field

    thank your for your time and help... but i am unable to understand...... can you give your chat is so i can understand better...............please help me
    Last edited by romperstomper; 06-17-2011 at 07:53 AM. Reason: remove unnecessary quote

  10. #10
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    6,176

    Re: Extract number from text field

    maybe this:

    =LOOKUP(99^99,--MID(RIGHT(C2,15),MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},RIGHT(C2,15)&"0123456789")),ROW($A$1:$A$10)))
    "Relax. What is mind? No matter. What is matter? Never mind!"

  11. #11
    Registered User
    Join Date
    06-16-2011
    Location
    hyderabad
    MS-Off Ver
    Excel 2003
    Posts
    30

    Re: Extract number from text field

    can you give your chat id so i need your help
    Last edited by romperstomper; 06-17-2011 at 07:53 AM. Reason: remove quote

  12. #12
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    6,176

    Re: Extract number from text field

    You can just write here. More people see it better help you'll get
    "Relax. What is mind? No matter. What is matter? Never mind!"

  13. #13
    Registered User
    Join Date
    06-16-2011
    Location
    hyderabad
    MS-Off Ver
    Excel 2003
    Posts
    30

    Re: Extract number from text field

    its working but when text is

    eg: pin 123434 VILLAGE+Post.Ahari, Dist.Jhajjar

    is showing error
    Last edited by romperstomper; 06-17-2011 at 07:54 AM.

  14. #14
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    6,176

    Re: Extract number from text field

    Well, if I extend it you will get 1 from:

    Mujeeb Pasha No 8,1St Floor Opp F,M Times Shop Someshwaranagar Jayanagr 1St Block Banglore:560011

    I think you need macro that would extract all numbers and take biggest
    "Relax. What is mind? No matter. What is matter? Never mind!"

  15. #15
    Registered User
    Join Date
    06-16-2011
    Location
    hyderabad
    MS-Off Ver
    Excel 2003
    Posts
    30

    Re: Extract number from text field

    if you are expert....
    you can solve understand and solve my problems ill pay you for your work...

    give me your chat id ....

    what say ?
    Last edited by romperstomper; 06-17-2011 at 07:54 AM.

+ 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.2.0