+ Reply to Thread
Results 1 to 15 of 15

how to use IF function with negative numbers

  1. #1
    Registered User
    Join Date
    07-21-2006
    Location
    Hull, England
    MS-Off Ver
    2007
    Posts
    99

    how to use IF function with negative numbers

    Hi all

    I need to get a result if W21 in both sheets are more than zero

    HTML Code: 
    Can anyone please tell me what needs to be changed in this formula for it to work

    Thanks

    loopiloo
    Last edited by FDibbins; 03-13-2013 at 12:09 AM.

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,065

    Re: IF function

    Something like
    =IF(AND('2011'!W21 > 0,'2012'!W21 > 0),"BOTH","NOT BOTH")
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    23,983

    Re: IF function

    =IF(and('2011'!$W21>0,'2012'!$W21>0),'2012'!H21-'2011'!H21,"-")

    Try this.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

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

    Re: IF function

    IF(and('2011'!$W21>0,'2012'!$W21>0),'2012'!H21-'2011'!H21,"-")
    "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

  5. #5
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: IF function

    Try it this way maybe:
    =IF(AND('2011'!$W21,'2012'!$W21>0),'2012'!H21-'2011'!H21,"-")

    The & is not an AND Comparator/Operator, it is basically a shorthand Method of Concatenating 2 text values together

    Hope this helps
    A picture may be worth a thousand words, BUT, a sample Workbook is worth a thousand screenshots!
    -Add a File - click advanced (next to quick post), scroll to manage attachments, click, select add files, click select files, select file, click upload, when file shows up at bottom left, click done (bottom right), click submit
    -To mark thread Solved- go top of thread,click Thread Tools,click Mark as Solved
    If you received helpful response, please remember to hit the * of that post

  6. #6
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,482

    Re: IF function

    Try this:
    =IF(MIN('2011'!$W21,'2012'!$W21)>0,'2012'!H21-'2011'!H21,"-")
    Quang PT

  7. #7
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,482

    Re: IF function

    Five replies within 2 minutes! Too fast to receiving Mod's warning of illegal title!

  8. #8
    Registered User
    Join Date
    07-21-2006
    Location
    Hull, England
    MS-Off Ver
    2007
    Posts
    99

    Re: IF function

    Thanks for all your replies guys... i used your formula alansidman, it worked fine.

  9. #9
    Registered User
    Join Date
    07-21-2006
    Location
    Hull, England
    MS-Off Ver
    2007
    Posts
    99

    Re: IF function

    The formula from alansidman worked fine, however i have another problem: some of the numbers in the calculation are negatives
    eg: -100 - 100 = 200
    Any ideas how i can get 0 with this example?
    ps: sorry if i used the wrong title... can i change it?

  10. #10
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: IF function

    To change your post title, go to your first post, edit post, change the thread title..(I think that's how it works, been awhile since I've had to do it)
    Note- If 2 days or more have passed, PM a forum Moderator to make the change for you ..

  11. #11
    Registered User
    Join Date
    07-21-2006
    Location
    Hull, England
    MS-Off Ver
    2007
    Posts
    99

    how to use IF function with negative numbers

    I really don't like to be dumb...! but, sorry ive tried and i don't know how to title this to be more relevant...
    Last edited by FDibbins; 03-13-2013 at 12:08 AM.

  12. #12
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,955

    Re: IF function

    I have changed your title for you
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  13. #13
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: how to use IF function with negative numbers

    I need to get a result if W21 in both sheets are more than zero
    So the question now becomes, what if either result =0 ?

    Posiible solutiion:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Hope this helps

  14. #14
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: how to use IF function with negative numbers

    Or, maybe, this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    After that, I would need to see a sample with some expected results to try anything different...

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

    Re: how to use IF function with negative numbers

    =IF(and('2011'!$W21>0,'2012'!$W21>0),max(0,'2012'!H21-'2011'!H21),"-")

+ 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