+ Reply to Thread
Results 1 to 9 of 9

IF greater than and less than

  1. #1
    Forum Contributor
    Join Date
    07-16-2007
    Posts
    174

    IF greater than and less than

    i understand how to use the IF formulae if the subject is greater than or less than

    eg =IF(B1>20,1,0) or =IF(B1<20,1,0)

    But how would i write this if i wanted, for example to equal 1 if B1 is greater than 10 and less than 20?

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Try

    =IF(AND(B1>10,B1<20),1,0)
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Contributor
    Join Date
    07-16-2007
    Posts
    174
    thanks alot!!

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582
    Both the OR and the AND Functions preceed their arguments
    Please Login or Register  to view this content.
    So for your specific example
    Please Login or Register  to view this content.
    Make sense?

    ChemistB

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,702
    You can also return the desired result with this formula

    =(B1>10)*(B1<20)

  6. #6
    Forum Contributor
    Join Date
    07-16-2007
    Posts
    174
    often, i do things but dont know why with excel, i just know they work. Yes, that actually does make sense now, Regards, Jamie

  7. #7
    Forum Contributor
    Join Date
    07-16-2007
    Posts
    174
    Quote Originally Posted by ChemistB
    Both the OR and the AND Functions preceed their arguments
    Please Login or Register  to view this content.
    So for your specific example
    Please Login or Register  to view this content.
    Make sense?

    ChemistB
    So if i wrote something like =IF(OR(B1>10,B6>10),True,fALSE)

    Would the cell = true if B1 is greater than 10, OR B6 greater than 10, otherwise false, or have i not quite got it?

    Only reason i ask is that if this is the case, i would find the OR function quite useful

  8. #8
    Forum Contributor
    Join Date
    07-16-2007
    Posts
    174
    second thoughts, why am i asking! i will open up a sheet and have a go!

  9. #9
    Forum Contributor
    Join Date
    07-16-2007
    Posts
    174
    yes it does, gotta stop asking for help before i have even tried!!

    learned 2 things here,

    1/ how 'or' and 'and' work
    2/ not to ask stupid questions without thinking!!

+ 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