+ Reply to Thread
Results 1 to 11 of 11

How to separate numbers from text in a code (into a separate column)

  1. #1
    Forum Contributor
    Join Date
    09-17-2009
    Location
    Torquay, England
    MS-Off Ver
    Excel 2013
    Posts
    253

    How to separate numbers from text in a code (into a separate column)

    Hi,

    I need to separate code so that the numeric section is displayed in a separate column: I don't want to use the TEXT TO COLUMNS FUNCTIONS as the text that is in the cell may vary in format - length - separators etc

    Please see attached the example

    I think I am looking for a function that will specifically search for the numbers and extract them.

    Thanks and regards
    Attached Files Attached Files
    Last edited by Gooford; 03-08-2012 at 10:33 AM.

  2. #2
    Registered User
    Join Date
    02-29-2012
    Location
    India, Bangalore
    MS-Off Ver
    Excel 2003 & Excel 2007
    Posts
    21

    Re: How to separate numbers from text in a code (into a separate column)

    Hi if it is similar like 4 digit number you can go with delimit function as show in the attached Excel sheet. Follow the steps in the sheet. I hope this will clarify you...

  3. #3
    Registered User
    Join Date
    02-29-2012
    Location
    India, Bangalore
    MS-Off Ver
    Excel 2003 & Excel 2007
    Posts
    21

    Re: How to separate numbers from text in a code (into a separate column)

    Hey sorry dear.... I wrongly updated it

  4. #4
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: How to separate numbers from text in a code (into a separate column)

    Hi

    You mean, something like this?

    =RIGHT(C5,4)
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

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

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  5. #5
    Forum Contributor
    Join Date
    09-17-2009
    Location
    Torquay, England
    MS-Off Ver
    Excel 2013
    Posts
    253

    Re: How to separate numbers from text in a code (into a separate column)

    Hi,

    Sorry no, I should have been more clear in my example - the original code can vary, e.g:

    AA1234

    BBBB - 233445

    AASFFHFHGH / 44326788

    In each case I just need to separate all the numbers in to a separate column (not using delimited function / text to columns)

    The RIGHT function wouldnt do as I cant be sure how many numbers there will be

  6. #6
    Forum Contributor
    Join Date
    09-19-2007
    Location
    Beirut
    MS-Off Ver
    0365 MSO Version 2109
    Posts
    207

    Re: How to separate numbers from text in a code (into a separate column)

    I had same issue before and someone gave me UDF code :

    Function NumberExtract(rngString As Range, Optional lngInstance As Long = 1) As Variant
    Dim RegExp As Object, RegExpMatch As Object
    On Error Resume Next
    Set RegExp = CreateObject("vbscript.regexp")
    With RegExp
    .Global = True
    .IgnoreCase = True
    .Pattern = "[0-9]+"
    End With
    Set RegExpMatch = RegExp.Execute(rngString)
    If lngInstance > RegExpMatch.Count Then
    NumberExtract = ""
    Else
    NumberExtract = RegExpMatch(lngInstance - 1)
    End If
    Set RegExpMatch = Nothing
    Set RegExp = Nothing
    End Function

    ================

    ssume string in A1, numbers to go in B1, C1 etc...

    Code:

    B1: =NUMBEREXTRACT($A1,COLUMNS($B1:B1))
    copied across

  7. #7
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: How to separate numbers from text in a code (into a separate column)

    Hi

    Then, try this..

    =LOOKUP(9^9,1*RIGHT(TRIM(C5),COLUMN($2:$2)))

    Is it, OK, now?

  8. #8
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: How to separate numbers from text in a code (into a separate column)

    @ Fotis, your formula will fail under certain conditions, see this workbook.

    The tried an tested old faithfull formula is
    Please Login or Register  to view this content.
    Attached Files Attached Files
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  9. #9
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: How to separate numbers from text in a code (into a separate column)

    Hi Marcol !

    Thank you for your coments.

    Yes i know this. I use different formula depanding on the case.

    I mean if the number, are on the right of the sentence, i use this formula. If is on the
    left in the sentence, i use, another formula.

    And if i want all the numbers that exists in a sentence, i use another formula.

    For words(letters), i use 3 different formula(left, middle, right).

    Sorry for my poor English.
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    09-17-2009
    Location
    Torquay, England
    MS-Off Ver
    Excel 2013
    Posts
    253

    Re: How to separate numbers from text in a code (into a separate column)

    Thanks everyone - very useful and some good options

  11. #11
    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,926

    Re: How to separate numbers from text in a code (into a separate column)

    Not sure if this is the right place for this question, but...how the heck does that formula work?? I have needed something like this before, so understanding how it works would be a great help
    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

+ 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