+ Reply to Thread
Results 1 to 8 of 8

if condition for range of values

  1. #1
    Registered User
    Join Date
    01-05-2010
    Location
    kansas city, us
    MS-Off Ver
    Excel 2007
    Posts
    11

    if condition for range of values

    Hi,

    I need help in writing a formula with if condition. I have a table as below

    -------A--------B--------C------D-------E (Column names)

    1------A--------B--------x1-----x2-----x3
    2------x1-------x2------1--------1-------0
    3------x5-------x6------0--------0-------0

    I tried with the formula: IF ($A2>=C$1,1,0) (Though incomplete)

    I would like to set a value of 0,1 if the column values (x1,x2,x3) lies within the range of values present in column A and B. Ex: x1 lies with x1 and x2 so set to 1 in the C2.

    I tried with different combinations but its not working. Can any one help me out on how to handle this condition. Thanks in advance.

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

    Re: if condition for range of values

    is that literally x1 or is it a number?
    if its number values
    =--AND(C$1>=$A2,C$1<=$B2)
    Last edited by martindwilson; 07-10-2010 at 01:27 PM.
    "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

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,697

    Re: if condition for range of values

    Try using AND, i.e.

    =IF(AND($A2<=C$1,$B2>=C$1),1,0)
    Audere est facere

  4. #4
    Registered User
    Join Date
    01-05-2010
    Location
    kansas city, us
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: if condition for range of values

    ...i could resolve this by myself . I tried similarly with one in last post. Thanks for the quick responses. I appreciate your help.

  5. #5
    Registered User
    Join Date
    01-05-2010
    Location
    kansas city, us
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: if condition for range of values

    I would like to extend this question..

    1------A--------B----C---------x1------x2-----x3
    2------x1-------x2---obj1------1--------1-------0
    3------x4-------x6---obj1------0--------0-------0
    4------x5-------x6---obj2------0--------0-------0

    I'm using the above columns x1, x2, x3 in a pivot table...

    I kept x1, x2, x3 in Values section. (which will appear in pivot table as Count of x1, Count of x2)
    and column C in Row Labels Section.

    Count of x1 is displaying a value of 2 for obj1...I'm expecting that count of x1 will display the values which are set to 1 (i.e Count of x1 should be 1). Is it possible to do this in pivot table?. Please let me know.

  6. #6
    Registered User
    Join Date
    01-05-2010
    Location
    kansas city, us
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: if condition for range of values

    I could change this by selecting Sum of X1 instead of Count of X1...

  7. #7
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: if condition for range of values

    Hi,
    please start a new thread with your new question, it will be easier for others to take advantage of the solutions,. Don't forget to change the title accordingly.
    Cheers

  8. #8
    Registered User
    Join Date
    01-05-2010
    Location
    kansas city, us
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: if condition for range of values

    Sorry, I will update it from the next time.

+ 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