+ Reply to Thread
Results 1 to 4 of 4

Need code to pull numeric data out of an alphanumeric string (string not constant)

  1. #1
    Registered User
    Join Date
    04-08-2011
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    30

    Need code to pull numeric data out of an alphanumeric string (string not constant)

    Hello Excel Gurus,

    Need your help with pulling some numeric data out of a string with alphanumeric text. I am having trouble using a command like "RIGHT" because the size and format of the string is not constant. What I mean is that the number of characters prior to or preceeding the data I need is not always the same. I still need the non-numeric text, I just need it seperated into a different column.

    So, what I really would need is the following in the attached spreasheet.

    1) In column B, I need the actual rate, which is only the NUMERIC information contained in column B already.
    2) In column C, I need all the NON-NUMERIC text that proceeds the NUMERIC information that is currently in column B.
    3) All information that follows the NUMERIC information in column B can be discarded.

    So, right now, this is and example of what you see in column B - Variable 0.03947 kwh

    What I would need is something like this:

    Column B: 0.03947
    Column C: Variable

    Any help would be GREATLY appreciated.

    Thanks for all your help.

    Harry
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Need code to pull numeric data out of an alphanumeric string (string not constant)

    In C2... =IF(B2<>"",MID(B2,(FIND(" ",TRIM(B2),1))+2,(FIND(" ",TRIM(B2),(FIND(" ",TRIM(B2),1))+1))-(FIND(" ",TRIM(B2),1))),"")
    In D2....=IF(B2<>"",LEFT(B2,FIND(" ",TRIM(B2),1)+1),"")

    Copy C2:D2 and paste down through the table
    Elegant Simplicity............. Not Always

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

    Re: Need code to pull numeric data out of an alphanumeric string (string not constant)

    Your profile states 2003, but your sample is 2007 or above.

    This should work for either.

    1/. Insert two columns after Column B "Rate"

    2/. Put this formula in C2, Drag across to D2, then down as required.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    3/. Copy Columns C:D and paste special > Values if required.

    This trims the results and returns a number rather than a string for your rates.
    Last edited by Marcol; 04-09-2013 at 12:39 PM.
    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.

  4. #4
    Registered User
    Join Date
    04-08-2011
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Need code to pull numeric data out of an alphanumeric string (string not constant)

    Worked perfectly.

    Thanks!

+ 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