+ Reply to Thread
Results 1 to 7 of 7

Extract Number from String Help

  1. #1
    Registered User
    Join Date
    11-16-2010
    Location
    Houston
    MS-Off Ver
    Excel 2003
    Posts
    4

    Extract Number from String Help

    Good morning, new member here. I need your help!!

    Basically, I need a macro that extracts the 3,4,or 5 digit number after "VTF" in the Reference column and puts the extracted number into the "Number" column.

    Reference---------------------------------------------------------------Number

    SCS VTF-932 - WELD PROCEDURES-------------------------------932
    SCS VTF -1017- PALL - INSPECTION & TEST PLAN----------1017
    SCS VTF- 1080 - LIST, TERMINAL JUNCTION-------------------1080
    123 SCS VTF - 1157-BILL OF MATERIALSCO1004/3008-----1157
    SCS 111 VTF-1181- 2 INSTRUCTIONS HX9008/2998----------1181
    KR-SS-T-0451 SCS VTF-1146 -PROCEDURES 2 --------------0451


    **** Note, sometimes there would be a space between the number and "-" some times there are none. Thank you and I would appreciate any help.
    Last edited by kobe4ever8; 03-31-2011 at 02:27 PM.

  2. #2
    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: Extract Number from String Help

    Try this formula
    Assuming your data is in Column A beginning Row 2.
    In B2
    Please Login or Register  to view this content.
    Drag/Fill Down

    Hope this helps
    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.

  3. #3
    Registered User
    Join Date
    11-16-2010
    Location
    Houston
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Extract Number from String Help

    thank you Marcol for the quick reply, your formula works on the first 5 rows.

    Reference---------------------------------------------------------------Number

    SCS VTF-932 - WELD PROCEDURES-------------------------------932
    SCS VTF -1017- PALL - INSPECTION & TEST PLAN----------1017
    SCS VTF- 1080 - LIST, TERMINAL JUNCTION-------------------1080
    123 SCS VTF - 1157-BILL OF MATERIALSCO1004/3008-----1157
    SCS 111 VTF-1181- 2 INSTRUCTIONS HX9008/2998----------1181
    KR-SS-T-0451 SCS VTF-1146 -PROCEDURES 2 --------------SS

    -- reason is (i'm assuming) that your formula finds the data between the first two "-", so that last one actually yields "SS" because thats the data between the first two "-"

    Thanks!

  4. #4
    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: Extract Number from String Help

    I take it that
    KR-SS-T-0451 SCS VTF-1146 -PROCEDURES 2
    Should return 1146 and not 0451

    How posting about a sample workbook showing a range of values that might throw out the formula/code?


    From Forum FAQs

    How do I attach a file to a post?

    To attach a file to your post, you need to be using the main 'New Post' or 'New Thread' page and not 'Quick Reply'. To use the main 'New Post' page, click the 'Post Reply' button in the relevant thread.

    On this page, below the message box, you will find a button labelled 'Manage Attachments'. Clicking this button will open a new window for uploading attachments. You can upload an attachment either from your computer or from another URL by using the appropriate box on this page. Alternatively you can click the Attachment Icon to open this page.

    To upload a file from your computer, click the 'Browse' button and locate the file. To upload a file from another URL, enter the full URL for the file in the second box on this page. Once you have completed one of the boxes, click 'Upload'.

    Once the upload is completed the file name will appear below the input boxes in this window. You can then close the window to return to the new post screen.

  5. #5
    Registered User
    Join Date
    11-16-2010
    Location
    Houston
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Extract Number from String Help

    Here is the sample data. Thank you for your help.
    Attached Files Attached Files

  6. #6
    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: Extract Number from String Help

    As I suspected there are a few "anomolies" in the data you have.

    Try this in B7
    Please Login or Register  to view this content.
    Drag/Fill Down
    This seems to cover all the data you have provided.

    If you need the result as a number and not text use this
    Please Login or Register  to view this content.
    The last part *1 forces the result to a number.
    The Cells can then formatted
    Format > Format Cells....
    Number > Custom
    Type:= "0000" (The number zeros to display, so 123 will display 0123)

    I have left a worksheet in the work book to let you see an easy way to build a complicated formula.

    Hope this helps
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    11-16-2010
    Location
    Houston
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Extract Number from String Help

    Thank you Thank you!!! You are good! I will look at the formula and try to grasp the concept behind it.

+ 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