+ Reply to Thread
Results 1 to 7 of 7

extracting negative numbers

  1. #1
    Forum Contributor
    Join Date
    07-20-2009
    Location
    philippines
    MS-Off Ver
    Excel 2007
    Posts
    203

    extracting negative numbers

    hi! I want to ask help from you guys,


    I used this code to extract the value on the text: "11/09/09 backyard $400"

    =IF(ISNUMBER(SEARCH("back",A4)),RIGHT(A4,LEN(A4)-FIND("$",A4))+0,"")


    and return "400" but i've encountered a value which is negative (could be
    -$400, or ($400); and i got an error of #value, could anyone resolve this problem?



    Thanks!
    Last edited by darkhangelsk; 08-17-2009 at 10:29 AM.

  2. #2
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: extracting negative numbers

    Maybe this would help

    Please Login or Register  to view this content.
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: extracting negative numbers

    assuming (400) means negative
    =IF(AND(ISNUMBER(search("back",A4)),OR(ISNUMBER(FIND("-$",A4)),ISNUMBER(search("(*)",A4)))),RIGHT(SUBSTITUTE(SUBSTITUTE(A4,")",""),"(","$"),LEN(SUBSTITUTE(SUBSTITUTE(A4,")",""),"(","$"))-FIND("$",SUBSTITUTE(SUBSTITUTE(A4,")",""),"(","$")))*-1,IF(ISNUMBER(SEARCH("back",A4)),RIGHT(A4,LEN(A4)-FIND("$",A4))+0,""))
    Last edited by martindwilson; 08-17-2009 at 10:19 AM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  4. #4
    Forum Contributor
    Join Date
    07-20-2009
    Location
    philippines
    MS-Off Ver
    Excel 2007
    Posts
    203

    Re: extracting negative numbers

    it's working but how about my first coding? can i use


    =IF(ISNUMBER(SEARCH("iNSP",A29)),RIGHT(A29,LEN(A29)-FIND("$",A29))+0,"")&if(--MID(SUBSTITUTE(TRIM(A31)," ","@",LEN(A31)-LEN(SUBSTITUTE(A31," ",""))),FIND("@",SUBSTITUTE(TRIM(A31)," ",)...



  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: extracting negative numbers

    Try

    =IF(ISNUMBER(SEARCH("back",A4)),TRIM(RIGHT(SUBSTITUTE(A4," ",REPT(" ",9)),9))+0,"")

    Note: the above works if your default currency is $, if not then amend to

    =IF(ISNUMBER(SEARCH("back",A4)),SUBSTITUTE(TRIM(RIGHT(SUBSTITUTE(A4," ",REPT(" ",9)),9)),"$","")+0,"")
    Last edited by daddylonglegs; 08-17-2009 at 10:25 AM.

  6. #6
    Forum Contributor
    Join Date
    07-20-2009
    Location
    philippines
    MS-Off Ver
    Excel 2007
    Posts
    203

    Re: extracting negative numbers

    Gosh! Martin again to save the day!


    Thanks to both of you, i know the codings were very messy at this time, but still very useful... Thanks!!!


    but wait...

    daddy's code were working also, and it's look like very simple... Thanks for the three of you! Really appreciate it!
    Last edited by darkhangelsk; 08-17-2009 at 10:28 AM.

  7. #7
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: extracting negative numbers

    DLL 's is shorter! and works
    i didnt know (4000)+0 resolves to negative!
    Last edited by martindwilson; 08-17-2009 at 10:34 AM.

+ 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