+ Reply to Thread
Results 1 to 23 of 23

IF/AND/THEN Formula

  1. #1
    Forum Contributor
    Join Date
    08-25-2013
    Location
    Virginia, USA
    MS-Off Ver
    Excel 2013
    Posts
    205

    IF/AND/THEN Formula

    **I made a mistake in my initial posting which is why a formula could not be made. THIS is the correct and complete listing of possibilities for values and expected values (if/then/and formula).**

    Does anyone know how to write an IF/THEN/AND formula that meets the following criteria for J1 that I can copy/paste down for all remaining cells? An example of the expected results is in the attached file.

    Column E will only have the values (1,2,OR 3)
    Column F will only have the values (W OR L)
    Columns G & H will only have the values (any whole number from 350 to -350)

    01) IF E1=1 AND F1=W AND G1>=-150 THEN J1=H1

    02) IF E1=1 AND F1=W AND G1<-150 THEN J1=0

    03) IF E1=1 AND F1=L AND G1>=-150 AND E2=1 THEN J1=H1

    04) IF E1=1 AND F1=L AND G1<-150 AND E2=1 THEN J1=0



    05) IF E1=1 AND F1=L AND G1>=-150 AND E2=2 AND F2=W AND G2>=-150 THEN J1=(H2*2)+H1

    06) IF E1=1 AND F1=L AND G1>=-150 AND E2=2 AND F2=W AND G2<-150 THEN J1=H1

    07) IF E1=1 AND F1=L AND G1<-150 AND E2=2 AND F2=W AND G2>=-150 THEN J1=H2

    08) IF E1=1 AND F1=L AND G1<-150 AND E2=2 AND F2=W AND G2<-150 THEN J1=0



    09) IF E1=1 AND F1=L AND G1>=-150 AND E2=2 AND F2=L AND G2>=-150 AND E3=3 AND G3>=-150 THEN J1=(H3*3)+(H2*2)+H1 (no, it doesn't matter what the value of F3 is in the instances below)

    10) IF E1=1 AND F1=L AND G1>=-150 AND E2=2 AND F2=L AND G2<-150 AND E3=3 AND G3>=-150 THEN J1=(H3*2)+H1

    11) IF E1=1 AND F1=L AND G1>=-150 AND E2=2 AND F2=L AND G2>=-150 AND E3=3 AND G3<-150 THEN J1=(H2*2)+H1

    12) IF E1=1 AND F1=L AND G1<-150 AND E2=2 AND F2=L AND G2<-150 AND E3=3 AND G3<-150 THEN J1=0

    13) IF E1=1 AND F1=L AND G1<-150 AND E2=2 AND F2=L AND G2>=-150 AND E3=3 AND G3<-150 THEN J1=H2

    14) IF E1=1 AND F1=L AND G1<-150 AND E2=2 AND F2=L AND G2<-150 AND E3=3 AND G3>=-150 THEN J1=H3
    Attached Files Attached Files
    Last edited by quibilty; 12-16-2015 at 01:18 AM. Reason: Initial Posting Was Incorrect

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,917

    Re: IF/AND/THEN Formula

    What is the point of the first section of each line (IF E1 = 1, etc.)? From your sample sheet, it appears that these numbers will not change.
    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.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Contributor
    Join Date
    08-25-2013
    Location
    Virginia, USA
    MS-Off Ver
    Excel 2013
    Posts
    205

    Re: IF/AND/THEN Formula

    It's possible that the data entered will look like this: (see attached)
    Attached Files Attached Files

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,917

    Re: IF/AND/THEN Formula

    Are there any other variables we need to know about before anyone tries writing a formula for you?

  5. #5
    Forum Contributor
    Join Date
    08-25-2013
    Location
    Virginia, USA
    MS-Off Ver
    Excel 2013
    Posts
    205

    Re: IF/AND/THEN Formula

    No, those are the only variables.

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

    Re: IF/AND/THEN Formula

    Your criteria statement has a gap in G1,2,3=-151.
    Quang PT

  7. #7
    Forum Contributor
    Join Date
    08-25-2013
    Location
    Virginia, USA
    MS-Off Ver
    Excel 2013
    Posts
    205

    Re: IF/AND/THEN Formula

    IF G1,2,3 is < or = -151 then treat as <-151. So, -150 or higher or -151 or fewer (only whole numbers used in G).

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

    Re: IF/AND/THEN Formula

    Does table in E1:J12 look exactly as it appears, or is it sample table only?

    If it is sample table only, look like in your actual sheet, E1,E2,E3; F1,F2,F3; G1,G2,G3 is given datas and J1 is target, J4:J12 is blank or other data that is not involving.

    Is it?

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

    Re: IF/AND/THEN Formula

    See attachment
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    08-25-2013
    Location
    Virginia, USA
    MS-Off Ver
    Excel 2013
    Posts
    205

    Re: IF/AND/THEN Formula

    It is a sample table only and J1 is target. There is no other data involved.

  11. #11
    Forum Contributor
    Join Date
    08-25-2013
    Location
    Virginia, USA
    MS-Off Ver
    Excel 2013
    Posts
    205

    Re: IF/AND/THEN Formula

    That formula is very close, but when I copy/paste it to actual file it doesn't work for all variables. See attached. Non highlighted values are correct, yellow highlighted values are incorrect in column "J" and the expected value is in column "K".
    Attached Files Attached Files

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

    Re: IF/AND/THEN Formula

    For instance, F13,14,15=W,L,W corresponds to E13,14,15=1,2,3 is not stated in your initial statement in #1.

    What are full criterias?

  13. #13
    Forum Contributor
    Join Date
    08-25-2013
    Location
    Virginia, USA
    MS-Off Ver
    Excel 2013
    Posts
    205

    Re: IF/AND/THEN Formula

    The full criteria is listed in the original question. In order to find a formula the works just change the values E1,E2,E3,F1,F2,F3,G1,G2,& G3.

    So, in "3 EXAMPLE" if you change the value of G1 to "-150" then J1 should be "100".

    OR

    If you change the value of F1 to "L", G1 to "-150", & G2 to "-190" then J1 would be "-150"

    and so on.

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

    Re: IF/AND/THEN Formula

    I think the best way to deal with this such complicated criteria is creating a lookup table. Could you try it?

  15. #15
    Forum Contributor
    Join Date
    08-25-2013
    Location
    Virginia, USA
    MS-Off Ver
    Excel 2013
    Posts
    205

    Re: IF/AND/THEN Formula

    I don't know how to do that, sorry.

  16. #16
    Forum Contributor
    Join Date
    08-25-2013
    Location
    Virginia, USA
    MS-Off Ver
    Excel 2013
    Posts
    205

    Re: IF/AND/THEN Formula

    Maybe this will help. I have a formula in column "L" that allows me to calculate for E2 & E3, all I'm looking to do is add E1. While the formula in "L" is different from what I'm looking for perhaps it can be used as a starting point?
    Attached Files Attached Files

  17. #17
    Forum Expert José Augusto's Avatar
    Join Date
    10-29-2014
    Location
    Portugal
    MS-Off Ver
    2013-2016
    Posts
    3,329

    Re: IF/AND/THEN Formula

    Hi
    I suppose I am thinking correctly, but ...

    Try the following formula

    =IF(E1=1,IF(F1="W",(G1>-151)*H1,IF(F2="W",SUMPRODUCT(--(G1:G2>-151),H1:H2,ROW($A$1:$A$2)),SUMPRODUCT(--(G1:G3>-151),H1:H3,ROW($A$1:$A$3)))),"")
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    I think the value you put into J4 is not correct. All other values are according to the logical formula expressed.

    If your problem is resolved mark it as "SOLVED".

    See the file 3 EXAMPLE.xlsx

    Regards

  18. #18
    Forum Contributor
    Join Date
    08-25-2013
    Location
    Virginia, USA
    MS-Off Ver
    Excel 2013
    Posts
    205

    Re: IF/AND/THEN Formula

    That is very close, J.A. J4's value was correct in the example. If you look at the original 18 sets of outcomes on 1st post you'll see J4 models after the 18th posted criteria (one at very bottom of page).

  19. #19
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: IF/AND/THEN Formula

    Hi quibility,

    I've made a flow chart of your "Iffenings" and it looks as though there are 4 unidentified possibilities - take a look and see whether I've filled it in correctly:

    IFFFFFFF.jpg
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

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

    Re: IF/AND/THEN Formula

    I made a lookup table template for you, in which 3 criterias are updated.
    Try to update all remain criterias, E for horizontal and F & G for vertical, the intersection is result.
    Attached Files Attached Files

  21. #21
    Forum Contributor
    Join Date
    08-25-2013
    Location
    Virginia, USA
    MS-Off Ver
    Excel 2013
    Posts
    205

    Re: IF/AND/THEN Formula

    My apologies, everyone. I made some mistakes in my initial posting. I changed my initial post and hopefully the new information will lead to a formula.
    Last edited by quibilty; 12-16-2015 at 03:23 AM.

  22. #22
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: IF/AND/THEN Formula

    It looks like there are still some mistakes in your post. I haven't checked to see if the gaps in the criteria that others have mentioned are now covered, but referring to your duplicate thread...
    Quote Originally Posted by quibilty View Post
    I'm looking for the first occurrence of a W in the three rows. If a W occurs in F1 then only the data in row 1 is incorporated. If G1 is >=-150 then J1 = H1. If G1 <-150 then J1 = 0. I.E., examples 1 & 2
    How do you explain conditions 3 and 4? They don't meet the criteria of 'first occurrence of W'

  23. #23
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: IF/AND/THEN Formula

    This is my best guess based on what you have provided for us to work with in both threads.

    PHP Code: 
    =CHOOSE(IFERROR(MATCH("W",F1:F3,0),3),
    IF(
    G1<-150,0,H1),
    CHOOSE(MATCH(--(--(G1<-150)&--(G2<-150)),{0,1,10,11},0),(H2*2)+H1,H1,H2,0),
    CHOOSE(MATCH(--(--(G1<-150)&--(G2<-150)&--(G3<-150)),{0,1,10,11,100,101,110,111},0),(H3*3)+(H2*2)+H1,(H2*2)+H1,(H3*2)+H1,"IDK","DBA",H2,H3,0)) 
    I've split the formula over 4 lines, the first line finds which of the 3 rows contains the first instance of 'W', defaulting to the 3rd row if there is no match. The remaining 3 rows hold the calculations to use based on which row holds the first 'W'.

    There was no criteria specified for 'W' in F3, with G1>-150, G2<-150 and G3<-150, or with G1<-150, G2>-150 and G3>-150, if the formula detects either of these combinations then you will be advised of the uncertainty.

+ 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. Replies: 11
    Last Post: 06-06-2014, 03:34 PM
  2. how to hide formula in formula box, view lookup result in formula box?
    By vengatvj in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-14-2013, 04:06 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