+ Reply to Thread
Results 1 to 12 of 12

Simultaneous 'if' statements

  1. #1
    Registered User
    Join Date
    02-11-2014
    Location
    Wales
    MS-Off Ver
    Excel 2010
    Posts
    12

    Simultaneous 'if' statements

    Hi,

    I was hoping someone might be able to help me solve a problem:

    I am trying to compare two sets of data: column A and column B - both contain data with 4 characters.

    I have compared column A and column B such that column C contains 'TRUE' if A&B are the same and 'FALSE' if they are not.

    I now want column D, to read 'FALSE' if column A & B do not start with the same letter and 'TRUE' if they do but only for the columns that read 'FALSE' in column C.

    IF column C = FALSE, AND IF column A and B start with the same letter, column D = TRUE
    IF column C = FALSE, AND IF column A and B dont start with the same letter, column D = FALSE

    e.g.

    Column A Column B Column C Column D
    D714 D56X FALSE TRUE
    F498 F498 TRUE
    D714 K875 FALSE FALSE

    I also need to count the TRUE's and FALSE's in column D - will this be affected by the blanks?

    Thank you :-)

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Simultaneous 'if' statements

    Try

    =AND(NOT(C1),LEFT(A1)=LEFT(B1))

  3. #3
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Simultaneous 'if' statements

    =if(c1=false,and(left(a1,1)=left(b1,1)),"")

    Edit The 2nd parameter of left is optional? Mind = blown.
    Last edited by daffodil11; 02-11-2014 at 02:40 PM.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

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

    Re: Simultaneous 'if' statements

    col c =a1=b1
    col d =IF(C1,"",LEFT(A1)=LEFT(B1))
    Last edited by martindwilson; 02-11-2014 at 02:40 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

  5. #5
    Forum Expert ben_hensel's Avatar
    Join Date
    01-26-2012
    Location
    Northeast USA
    MS-Off Ver
    Office 365
    Posts
    2,043

    Re: Simultaneous 'if' statements

    So like this:

    A1 = first_string
    B1 = second_string
    C1 = IF(A1=B1, TRUE, FALSE)
    D1 = IF(C1=TRUE, "", IF( LEFT(A1, 1) = LEFT(B1, 1), TRUE, FALSE))

    Then counting:
    E1 = countif(C:C, TRUE)

    E2 = countif(D:D, TRUE)

    probably you want E1+E2 as your output for TRUEs here?

    E3 = countif(D:D, FALSE)

  6. #6
    Registered User
    Join Date
    06-09-2012
    Location
    India
    MS-Off Ver
    Excel 2007, 2010, 2013
    Posts
    26

    Re: Simultaneous 'if' statements

    Hi Ant123,

    I think I've found a solution. It goes like this:
    =IF(AND((C3=FALSE),LEFT(B3,1)=LEFT(A3,1)),"TRUE","FALSE")

    Let me know if it worked.

    Btw, this is my very first attempt at solving a problem in excel. I'm quite new to it. So please excuse if there's a fault with the formula. :-)

    Thanks,
    asar_k

  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: Simultaneous 'if' statements

    ben you dont need to test for = true if the thing you are testing is true/false or even 1/0 if(c1,1,2) will evaluate based on true/false in b1 so if b1 is true it returns 1 if false 2
    similarly =a1=b1 will happily produce true/false without any IF() used
    also left(a1,1) is the same as just left(a1)

  8. #8
    Forum Expert ben_hensel's Avatar
    Join Date
    01-26-2012
    Location
    Northeast USA
    MS-Off Ver
    Office 365
    Posts
    2,043

    Re: Simultaneous 'if' statements

    I was going for "explicit" rather than "efficient".

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

    Re: Simultaneous 'if' statements

    @ben fair point

  10. #10
    Registered User
    Join Date
    02-11-2014
    Location
    Wales
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Simultaneous 'if' statements

    Hi All,

    Thank you so much for your answers! They are a great help!

    @ Asar_k and jonmo1: your formulas worked except that it did not leave a blank column if C1 = TRUE

    @daffodil11, ben_hensel, martindwilson - all worked thank you!

    I have used: IF(C1=TRUE, "", IF( LEFT(A1, 1) = LEFT(B1, 1), TRUE, FALSE)) as I am new to this so it helps me understand what I am asking Excel to do.

    Just to check, am I telling Excel: if C1 reads true, put a blank space and for all others (not sure why I dont need 'IF C1 = FALSE?), if the first character from the left in A1 and the first character from the left in B1 are the same, designate 'TRUE' and if not 'FALSE'?

    Thank you :-)

  11. #11
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,412

    Re: Simultaneous 'if' statements

    Quote Originally Posted by Ant123 View Post
    ... (not sure why I dont need 'IF C1 = FALSE?) ...
    The IF function tests for an EITHER / OR situation. You can think of it as:

    =IF(Condition_to_be_tested, Action_if_TRUE, Action_if_FALSE)

    so if the condition is TRUE then the first action will be carried out, if it is FALSE then the second action will be evaluated. Thus if you test for IF(C1=TRUE,... (or more simply IF(C1,... ) then you don't also need to test for IF(C1=FALSE,... as that is implied in the second action.

    Hope this helps.

    I'm sure the contributors are grateful for your feedback, but if the answers take care of your original question, please select Thread Tools from the menu above your first post and mark this thread as SOLVED.

    Also, since you are relatively new to the forum, I would like to inform you that you can directly thank those who have helped you by clicking on the small "star" icon located in the lower left corner of a post that you have found to be helpful (not just in this thread - for any post that has helped you). This also adds to the reputation of the poster (the small green bars in the poster's profile).

    Pete

  12. #12
    Registered User
    Join Date
    02-11-2014
    Location
    Wales
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Simultaneous 'if' statements

    Hi Pete,

    Thanks very much for the information. It is a great help! :-)

+ 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. Simultaneous Update
    By arlu1201 in forum The Water Cooler
    Replies: 16
    Last Post: 02-27-2012, 08:12 AM
  2. Simultaneous view
    By NickJW in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-25-2010, 01:01 PM
  3. simultaneous protection
    By Sebastian1942 in forum Excel General
    Replies: 9
    Last Post: 12-22-2009, 10:41 AM
  4. [SOLVED] Simultaneous Filtering
    By Mike in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-25-2006, 03:25 AM
  5. [SOLVED] simultaneous pairings
    By rvallin103129mi@comcast.net in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-13-2005, 03:05 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