+ Reply to Thread
Results 1 to 14 of 14

Using "if" and "or" together

  1. #1
    Forum Contributor
    Join Date
    07-16-2004
    Location
    Illinois
    MS-Off Ver
    Office 365
    Posts
    122

    Using "if" and "or" together

    Hello everybody. I am trying to write a formula to do something simple, I'm just having trouble writing it.

    The formula I am trying to write is going in column I, and looks at cloumn A.

    I want the cell in column I to display one of four values if a certain number in column A is displayed.

    somehing along the lines of this:

    if(a2=(1:28 or 58:117or145:174),"03X05", if(a2=(29:45 or 118:132,)"03X10").

    Any help would be greatly appreciated. Thank you in advance.

  2. #2
    Forum Contributor
    Join Date
    05-29-2009
    Location
    Kalgoorlie Australia
    MS-Off Ver
    Excel 2007/10
    Posts
    251

    Re: Using "if" and "or" together

    Please attach a copy for us to see
    Regards
    Peter

  3. #3
    Forum Contributor
    Join Date
    07-16-2004
    Location
    Illinois
    MS-Off Ver
    Office 365
    Posts
    122

    Re: Using "if" and "or" together

    Here is a sample spreadsheet of what I am trying to do.
    Attached Files Attached Files

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

    Re: Using "if" and "or" together

    =if(or(a2="1:28",a2="58:117",a2="145:174"),"03X05", if(or(a2="29:45",a2="118:132",)"03X10",""))

    Assuming all your test values are strings

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Using "if" and "or" together

    You are close with what you have.
    The following works for me. It is BLANK if no matches. NOTE - you must format column A cells as TEXT for this to work, otherwise Excel thinks they are times.

    Please Login or Register  to view this content.
    If you meant the cells in column A to be time then this doesn't work.
    Last edited by MarvinP; 09-11-2010 at 10:17 AM.

  6. #6
    Forum Contributor
    Join Date
    07-16-2004
    Location
    Illinois
    MS-Off Ver
    Office 365
    Posts
    122

    Re: Using "if" and "or" together

    Dear Arthurbr,

    I copied your formula to my sample spreadsheet and it is telling me "The formula you typed contains an error". Is there something wrong, or am I missing something?

  7. #7
    Forum Contributor
    Join Date
    07-16-2004
    Location
    Illinois
    MS-Off Ver
    Office 365
    Posts
    122

    Re: Using "if" and "or" together

    Dear MarvinP,

    I copied your formula to a different cell and all I am getting is a blank cell. I have formatted column A as text as per your instructions. I even took it a step further and formatted column A as numbers and am still getting a blank cell. I am using Excel 2003 SP3 if that makes a difference. And no, I do not mean for the values to be as time.
    Last edited by pboost1; 09-11-2010 at 11:20 AM.

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

    Re: Using "if" and "or" together

    There was a typo in my formula.
    But your A column does not contain any values as you described as xx:yy
    Do you mean that A2 should be BETWEEN1 and 28, etc...

  9. #9
    Forum Contributor
    Join Date
    07-16-2004
    Location
    Illinois
    MS-Off Ver
    Office 365
    Posts
    122

    Re: Using "if" and "or" together

    Correct, If A2 contains any value BETWEEN 1 and 28, or between 58 and 117, then display 03X05 in cell I2. If A2 contains any value BETWEEN 29 and 45 or between 118 and 132, then display 03X10. I will be sorting this and moving the cells in column A around.

    Example: on today I want cell A2 to contain a 1, displaying 03x05 in cell I2. Tomorrow I want cell A2 to contain 40, displaying 03X10 in cell I2. The following day cell A2 will contain 100, which will display 03X05 in cell I2.

    Sorry for the confusing posts. Thanks again in advance.
    Last edited by pboost1; 09-11-2010 at 01:33 PM. Reason: adding more info

  10. #10
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Using "if" and "or" together

    OHhhh Between......

    The reason for the blank in my formula is that if the text in column A isn't that exact strings my formula returns a blank.

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

    Re: Using "if" and "or" together

    Try this then

    =IF(OR(and(A2>=1,a2<=28),and(a2>=58,a2<=117),and(a2>=145,a2<=174)),"03X05","03X10")

  12. #12
    Forum Contributor
    Join Date
    07-16-2004
    Location
    Illinois
    MS-Off Ver
    Office 365
    Posts
    122

    Re: Using "if" and "or" together

    Dear MarvinP,

    Thank you, The formula you have provided seems to work. I just need to add a few more values to it, and your formula seems simple enough to be able to edit it. If I have any other problems I will reply to this. Thanks alot.

  13. #13
    Forum Contributor
    Join Date
    07-16-2004
    Location
    Illinois
    MS-Off Ver
    Office 365
    Posts
    122

    Re: Using "if" and "or" together

    Dear Arthurbr

    This is to inform you that your formula was the one that worked. Thank you for all that you have provided. Thank you MarvinP as well. It is working as needed even with the additional information I added. This thread can be marked closed. Thanks again.

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

    Re: Using "if" and "or" together

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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