+ Reply to Thread
Results 1 to 9 of 9

Use of OR and AND function in same nested function

Hybrid View

  1. #1
    Registered User
    Join Date
    09-10-2010
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    29

    Use of OR and AND function in same nested function

    This is driving me nuts and I can't see why what I am doing won't work.

    SR
    CL
    06:15

    06:15
    07:06
    07:07
    07:35
    07:36
    . . . .
    . . . .
    . . . .

    The letters SR and CL are in cells N38 and N39. They are code for an origin (N38) and a destination (N39). According to the pairing of these and other codes the vertical time output shown in (N42:N46) changes. The 06:15 is a start time.

    I am trying to write a formula for N47, which should be something like this

    =IF(OR(N$38="AY",N$38="GV”,N$38="SR”),AND(N$39="CL",N$39="KM")),N$46+$A$28, ". . . .")

    In other words if the following combination of origin and destination codes are put in to N38 and N39, (N$38="AY",N$38="GV”,N$38="SR”) and (N$39="CL",N$39="KM")), N47 will give me a result of adding a value to N46.

    Can someone advise what that forumals should be and the syntax to use as I've tried most combinations I can think of and get nothing like the answer I need!

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

    Re: Use of OR and AND function in same nested function

    AND(N$39="CL",N$39="KM") always return FALSE

    Maybe:

    =IF(AND(OR(N$38="AY",N$38="GV”,N$38="SR”),OR(N$39="CL",N$39="KM")),N$46+$A$28, ". . . .")
    Quang PT

  3. #3
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,115

    Re: Use of OR and AND function in same nested function

    the way you have the formula set out

    =IF(OR(N$38="AY",N$38="GV”,N$38="SR”),AND(N$39="CL",N$39="KM")),N$46+$A$28, ". . . .")

    OR(N$38="AY",N$38="GV”,N$38="SR”)
    this the test as you have one set of brackets and a comma
    so then the TRUE part is
    AND(N$39="CL",N$39="KM"))
    and also closes the IF statement completely

    the AND also can never be true
    AND(N$39="CL",N$39="KM")
    as the same cell cannot be two things at once

    what are the rules again

    you need to combine the two different cells

    can you write out - the result in a truth table

    N38 --- N39 Result
    AY --- CL --- ?
    GV --- CL --- ?
    SR --- CL --- ?
    AY --- SR --- ?
    GV --- SR --- ?
    SR --- SR --- ?

    from that you should be able to work out the where to use the AND / ORs
    Wayne
    if my assistance has helped, and only if you wish to , there is an "* Add Reputation" on the left hand side - you can add to my reputation here

    If you have a solution to your thread - Please mark your thread solved do the following: >
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  4. #4
    Registered User
    Join Date
    09-10-2010
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: Use of OR and AND function in same nested function

    Hi,

    It is the combination that is important.

    The origin cell N38 can be either (N$38="AY",N$38="GV”,N$38="SR”) and the destination cell either (N$39="CL",N$39="KM"). What is important here is the combinations which are

    AY-CL, AY-KM, GV-CL, GV-KM, SR-CL, SR-KM. If these combinations are true then the answer is N$46+$A$28. If not then ". . . ." is returned

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,774

    Re: Use of OR and AND function in same nested function

    =if(and(or(n$38="ay",n$38="gv",n$38="sr"),or(n$39="cl",n$39="km")),n$46+$a$28,"")
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  6. #6
    Registered User
    Join Date
    09-10-2010
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: Use of OR and AND function in same nested function

    Yes that has solved it! Thanks. It was the second OR that I wasn't getting.

    Cheers!

  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: Use of OR and AND function in same nested function

    you can shorten that a bit
    =IF(AND(OR(N$38={"ay","gv","sr"}),OR(N$39={"cl","km"})),N$46+$A$28,".......")
    Last edited by martindwilson; 03-15-2014 at 01:32 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

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,774

    Re: Use of OR and AND function in same nested function

    Quote Originally Posted by martindwilson View Post
    you can shorten that a bit
    =IF(AND(OR(N$38={"ay","gv","sr"}),OR(N$39={"cl","km"})),N$46+$A$28,"")
    Yes!

    =IF(AND(OR(N$38={"ay","gv","sr"}),OR(N$39={"cl","km"})),N$46+$A$28,". . . .")

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,774

    Re: Use of OR and AND function in same nested function

    =if(and(or(n$38="ay",n$38="gv",n$38="sr"),or(n$39="cl",n$39="km")),n$46+$a$28,". . . .")

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Nested Function With Division - Receiving #VALUE! Function Error
    By DDM64 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-17-2013, 01:16 PM
  2. Replies: 6
    Last Post: 12-14-2012, 10:43 PM
  3. [SOLVED] Nested AND function within IF function is only addressing logical1 but not logical2
    By betic in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-20-2012, 09:17 AM
  4. Replies: 9
    Last Post: 07-02-2012, 07:02 PM
  5. Offset function with nested match function not finding host ss.
    By MKunert in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-21-2006, 06:50 PM

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