+ Reply to Thread
Results 1 to 11 of 11

Combining if statements

  1. #1
    Forum Contributor
    Join Date
    05-27-2012
    Location
    New Brunswick, Canada
    MS-Off Ver
    Excel 2016
    Posts
    327

    Combining if statements

    Depending on what is manually added in Column D, I would like the time (which is basically extracting certain characters) to change. The formulas in E1, E2, E3 are working fine but when I try to write them all together in E4, I get "A Value used in this formula is of the wrong data type".

    Any ideas what's going on here? And/or how to resolve?
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    06-18-2014
    Location
    USA
    MS-Off Ver
    2013
    Posts
    142

    Re: Combining if statements

    Try wrapping the If statements in the IFERROR...it will check the first match (Column B from MU tab) and if it doesn't find it will then check Column E from MU tab, etc.

    The formula is cell E5 I tried was
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    05-27-2012
    Location
    New Brunswick, Canada
    MS-Off Ver
    Excel 2016
    Posts
    327

    Re: Combining if statements

    Thank you jjhayes. It doesn't seem to be doing anything when I populate anything from column H on the MU tab though. I can't seem to find anything wrong with the way you've written it to explain this though.

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Combining if statements

    I'm not sure what your logic is since you did not really explain the conditions or the results (I would like the time (which is basically extracting certain characters) ...)
    However, try, in E2, etc.:
    Please Login or Register  to view this content.
    The nested IFERROR statements are meant to return 1 if the first is false, i.e. found a match, 2 for the second, etc.
    The 1..4 is returned to the CHOOSE which points to one of the four MID formulas to evaluate.

    * Unmerge those cells in row three on MU tab. Use Center Across Selection formatting instead.

    Note that on the original worksheet, cell E5, you have three independent IF statements separated by commas. That is not a Nested IF statement structure.
    Last edited by protonLeah; 06-08-2016 at 01:30 AM.
    Ben Van Johnson

  5. #5
    Forum Contributor
    Join Date
    05-27-2012
    Location
    New Brunswick, Canada
    MS-Off Ver
    Excel 2016
    Posts
    327

    Re: Combining if statements

    Hi protonLeah,

    By "I would like the time (which is basically extracting certain characters)" what I mean is, for example in C2, it says "T 1645-1700". What I mean is I would to extract "1645" and then, depending on what is written in column D, I would like 1645 to do one of 3 things.
    if Column D is a number from Column B on MU tab - I would like 1645+300 so it would come out to 1945
    if Column D is a number from Column E on MU tab - I would like it left alone so it would come out to 1645
    if Column D is a number from Column H on MU tab - I would like 1645-100 so it would come out to 1545

    The answer you provided had 1 too many arguments but with a simple tweak, it seems to be doing exactly what I'd like it to do
    Last edited by Wheelie686; 06-08-2016 at 07:21 AM.

  6. #6
    Forum Contributor
    Join Date
    05-27-2012
    Location
    New Brunswick, Canada
    MS-Off Ver
    Excel 2016
    Posts
    327

    Re: Combining if statements

    Is there a way to rewrite it so if D is blank, then E won't give me a #VALUE? Currently I have the following

    =CHOOSE(IF(ISERROR(MATCH(D2,MU!B:B,0)),IF(ISERROR(MATCH(D2,MU!E:E,0)),IF(ISERROR(MATCH(D2,MU!H:H,0)),4,3),2),1),(MID(C2,3,4)+300)*1,MID(C2,3,4)*1,(MID(C2,3,4)-100)*1)

  7. #7
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Combining if statements

    maybe:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    concerning to #1
    Last edited by sandy666; 06-09-2016 at 06:09 PM.

  8. #8
    Forum Contributor
    Join Date
    05-27-2012
    Location
    New Brunswick, Canada
    MS-Off Ver
    Excel 2016
    Posts
    327

    Re: Combining if statements

    Thank you sandy but that just ends up putting the result of =MID(C5,3,4)

  9. #9
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Combining if statements

    right, because, e.g. if in IF(ISNA(MATCH(D5,MU!B:B,0)),MID(C5,3,4),MID(C5,3,4)+300) is TRUE result will be just MID(C5,3,4) and so on. If bolded part will be FALSE result will be MID(C5,3,4)+300).
    but if you want another value or not value you can change this MID(C5,3,4) (on the end of formula) to "" or 0.

    edit:
    or add another condition: IF(D5=0,"",your full formula) or IF(D5="","",your full formula)
    Last edited by sandy666; 06-09-2016 at 06:42 PM.

  10. #10
    Forum Contributor
    Join Date
    05-27-2012
    Location
    New Brunswick, Canada
    MS-Off Ver
    Excel 2016
    Posts
    327

    Re: Combining if statements

    Ah thank you! I guess that's what I get for using such a complicated formula

  11. #11
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Combining if statements


    If problem is resolved mark thread as solved (Over first post - Thread Tools - Mark thread as solved) Thank you.

+ 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] Combining IF Statements
    By RaydenUK in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 04-30-2014, 09:43 PM
  2. [SOLVED] Combining 2 IF Statements
    By cartica in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-22-2014, 07:33 AM
  3. Combining if with and statements
    By npjones1812 in forum Excel General
    Replies: 2
    Last Post: 03-20-2014, 05:16 PM
  4. [SOLVED] Combining 3 IF/AND statements with OR
    By lsargent in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-25-2012, 01:07 AM
  5. combining two if statements to one
    By excel_help_needed in forum Excel General
    Replies: 7
    Last Post: 10-28-2010, 07:04 AM
  6. combining two if then statements
    By wynsum in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 04-16-2009, 10:52 PM
  7. Help combining IF statements
    By Excel-erate2004 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-18-2007, 11:32 AM

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