+ Reply to Thread
Results 1 to 12 of 12

Vlookup formula - return only numbers for cells containing text and numbers

  1. #1
    Registered User
    Join Date
    06-26-2012
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    37

    Vlookup formula - return only numbers for cells containing text and numbers

    Please can somebody advise if this is possible....

    I want my vlookup formula to return only the numbers from a cell containing text, a currency sign, numbers and digit grouping commas

    The possibilities in the data range (table_array) cells are "we call/ we deliver/ we return £1 - £100,000,000.00" e.g. "we deliver €150,000.00" or "We return £9,700,000.00" and also "Below MTA". The amounts can be anything up to 500mill.

    The Vlookup formula needs to do the following:
    1. return only numbers
    2. We deliver and We return needs to be a negative amount
    3. We call needs to be a positive amount
    4. Below MTA needs to return 0

    E.g. if the data was "We deliver €150,000.00" I want the vlookup to return -150,000.00 (the format doesnt really matter as I can change this once the number has been returned), for "We Call $7,500,000.00" I want 7,500,000.00 returned and for "below MTA" I want 0 returned.

    Can any Excel boffin held with this? Any help is gratefully received. I have a manual work around for this but it would be magnificant if it could be automated.

    Cheers






    Any suggestions gratefully appreciated.
    Last edited by Andrew E Smith; 06-29-2012 at 08:23 AM.

  2. #2
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Vlookup formula - return only numbers for cells containing text and numbers

    Try this for Cell B2. It assumes all non-'below MTA' cells will necessarily start with 'we deliver/call'/return '

    =IF(B2="below MTA",0,IF(OR(MID(B2,FIND(" ",B2,1)+1,FIND(" ",B2,4)-4)="deliver",MID(B2,FIND(" ",B2,1)+1,FIND(" ",B2,4)-4)="return"),-RIGHT(B2,LEN(B2)-FIND(" ",B2,4)),RIGHT(B2,LEN(B2)-FIND(" ",B2,4))))
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  3. #3
    Registered User
    Join Date
    06-26-2012
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    37

    Re: Vlookup formula - return only numbers for cells containing text and numbers

    Thanks you very much thats spot on. You are a legend.

  4. #4
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Vlookup formula - return only numbers for cells containing text and numbers

    Glad it helps! Please mark the thread as 'Solved'

    To mark your thread solved do the following:
    - Go to the first post
    - Click edit
    - Click Advance
    - Just below the word "Title:" you will see a dropdown with the word No prefix.
    - Change to Solve
    - Click Save

  5. #5
    Registered User
    Join Date
    06-26-2012
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    37

    Re: Vlookup formula - return only numbers for cells containing text and numbers

    no prob, thanks again for your help

  6. #6
    Registered User
    Join Date
    06-26-2012
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    37

    Re: Vlookup formula - return only numbers for cells containing text and numbers

    Hi, there is 1 more condition I overlooked...

    I also need "below threshold" to return 0

    I dont understand why the following modification is returning #VALUE!

    =IF(OR(B2="below MTA","below threshold"),0,IF(OR(MID(B2,FIND(" ",B2,1)+1,FIND(" ",B2,4)-4)="deliver",MID(B2,FIND(" ",B2,1)+1,FIND(" ",B2,4)-4)="return"),-RIGHT(B2,LEN(B2)-FIND(" ",B2,4)),RIGHT(B2,LEN(B2)-FIND(" ",B2,4))))

    Where am I going wrong, please help.

    Thanks

  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: Vlookup formula - return only numbers for cells containing text and numbers

    Hi. Try

    =IF(OR(B2="below MTA",B2="below threshold"),0,IF(OR(MID(B2,FIND(" ",B2,1)+1,FIND(" ",B2,4)-4)="deliver",MID(B2,FIND(" ",B2,1)+1,FIND(" ",B2,4)-4)="return"),-RIGHT(B2,LEN(B2)-FIND(" ",B2,4)),RIGHT(B2,LEN(B2)-FIND(" ",B2,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.

  8. #8
    Registered User
    Join Date
    06-26-2012
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    37

    Re: Vlookup formula - return only numbers for cells containing text and numbers

    Thanks, man I am a newb.

  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: Vlookup formula - return only numbers for cells containing text and numbers

    You are welcome

  10. #10
    Registered User
    Join Date
    06-26-2012
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    37

    Re: Vlookup formula - return only numbers for cells containing text and numbers

    Another query....

    In reality, cell B2 is in a different spreadsheet and when you replace all the B2's in the formula with the destination spreadsheet it makes the formula very long. In some cases, where I need this formula, the destination spreadsheet is too long and Excel won't let me input the vlookup (error message saying formula too long pops up)

    Other than rename the spreadsheets so the file name is shorter in length (which I wish to avoid), the only other solution is to write the formula in visual basic and link it to the cell. Only problem is I'm not 100% sure how to do this or if it is possible....

    Any advice on how to do this? As always, any help much appreciated.

  11. #11
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Vlookup formula - return only numbers for cells containing text and numbers

    Shortened formula...interchanged the conditions and the signs..still works though!

    =IF(OR(B2="below MTA",B2="below threshold"),0,IF(MID(B2,FIND(" ",B2,1)+1,FIND(" ",B2,4)-4)="call",RIGHT(B2,LEN(B2)-FIND(" ",B2,4)),-RIGHT(B2,LEN(B2)-FIND(" ",B2,4))))

  12. #12
    Registered User
    Join Date
    06-26-2012
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    37

    Re: Vlookup formula - return only numbers for cells containing text and numbers

    Cheers pal, thats worked a treat

+ 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