+ Reply to Thread
Results 1 to 10 of 10

extract numbers from a cell, before a specific text

  1. #1
    Registered User
    Join Date
    06-14-2012
    Location
    Italy
    MS-Off Ver
    Excel 16.0
    Posts
    42

    extract numbers from a cell, before a specific text

    Hi, I have a column which stores info about cars, like
    q7 6.0 v12 tdi 500cv
    s 350 bluetec 4matic 3.0 v6 258cv
    I would like to extract just the number before "cv"; that would make
    500
    258

    How can I achieve that?

    Thanks for your help!

  2. #2
    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: extract numbers from a cell, before a specific text

    Try this:

    If item is in cell A1...

    =MID(A1,FIND("cv",A1)-3,3)

    Note: The result will be a text string. If you need the result to be numeric, you could change it to this:
    =MID(A1,FIND("cv",A1)-3,3)*1

    - Moo
    Last edited by Moo the Dog; 01-10-2013 at 12:47 PM. Reason: Added note.

  3. #3
    Registered User
    Join Date
    08-26-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    58

    Re: extract numbers from a cell, before a specific text

    try this...asuming that ur data is in A2

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    06-14-2012
    Location
    Italy
    MS-Off Ver
    Excel 16.0
    Posts
    42

    Re: extract numbers from a cell, before a specific text

    Thank you. Moo's formula seems to work a little better, though it's not applicable when I have 99cv or lower
    For instance, sbehera's give a "#VALUE!" error when the cell contains just "170cv"

    So let's say the formula should work in the following cases:
    170cv xxxx
    170cv
    xxxx 170cv
    xxxx 170cv xxxx
    50cv xxxx
    50cv
    xxxx 50cv
    xxxx 50cv xxxx
    always extracting only the number before "cv"

    Thanks again for your kind help!
    Last edited by xlepws; 01-11-2013 at 05:31 AM.

  5. #5
    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: extract numbers from a cell, before a specific text

    In your example i see that after ALL your numbers exist ALWAYS a "cv". Is like that and in your real sheet?
    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.

  6. #6
    Registered User
    Join Date
    08-22-2012
    Location
    Zagreb, Croatia
    MS-Off Ver
    Excel 2003
    Posts
    61

    Re: extract numbers from a cell, before a specific text

    Hi,
    try this, assuming have data in B3...

    Please Login or Register  to view this content.
    Regards,
    If a post helps press star sign 4 my reputation

  7. #7
    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: extract numbers from a cell, before a specific text

    Short and sweet:

    =IF(FIND("cv",A1)<4,LEFT(A1,2),TRIM(MID(A1,FIND("cv",A1)-3,3)))

    - Moo

  8. #8
    Registered User
    Join Date
    06-14-2012
    Location
    Italy
    MS-Off Ver
    Excel 16.0
    Posts
    42

    Re: extract numbers from a cell, before a specific text

    Quote Originally Posted by Fotis1991 View Post
    In your example i see that after ALL your numbers exist ALWAYS a "cv". Is like that and in your real sheet?
    Hi. No, because I could have a cell containing something like "q7 6.0 v12 tdi 500cv" as written in the 1st post thanks
    Last edited by xlepws; 01-11-2013 at 01:45 PM.

  9. #9
    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: extract numbers from a cell, before a specific text

    Does the updated formula in my post (#7) work for you?

  10. #10
    Registered User
    Join Date
    06-14-2012
    Location
    Italy
    MS-Off Ver
    Excel 16.0
    Posts
    42

    Re: extract numbers from a cell, before a specific text

    Quote Originally Posted by Moo the Dog View Post
    Does the updated formula in my post (#7) work for you?
    Yup, that works like a charm, I was about to write it

    thanks a lot!!

+ 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