+ Reply to Thread
Results 1 to 13 of 13

Trouble with Nested If

  1. #1
    Registered User
    Join Date
    07-25-2014
    Location
    Texas
    MS-Off Ver
    2010
    Posts
    4

    Trouble with Nested If

    Column L Column M
    306TRFKM (THREE FORKS MIDDLE) B
    306TRFKM (THREE FORKS MIDDLE) B
    306TRFKL (THREE FORKS LOWER) #VALUE!


    Formula for column M
    =IF(FIND("MIDDLE",L1,1)>0,"B",IF(FIND("LOWER",L1,1)>0,"A"))

    The formula only looks at the first "IF" statement and ignores the second. If I switch the IF statement so that I'm looking for "LOWER" first, it works for all the lowers but ignores the second IF and gives me a #Value for all of the middles.

    Any idea why this is happening?

  2. #2
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Trouble with Nested If

    Can you post a real workbook with sample data and a proposed outcome you are looking for?
    Please ensure you mark your thread as Solved once it is. Click here to see how.
    If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.

  3. #3
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: Trouble with Nested If

    You are telling the formula to find middle, not asking it whether middle exists. You could try an IFERROR in there if Middle and Lower are the only conditions

    =IFERROR(IF(FIND("MIDDLE",A4,1)>0,"B",""),"A")
    You should hit F5, because chances are I've edited this post at least 5 times.
    Example of Array Formulas
    Quote Originally Posted by Jacc View Post
    Sorry, your description makes no sense. I just made some formula that looks interesting cause I had nothing else to do.
    Click the * below on any post that helped you.

  4. #4
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,447

    Re: Trouble with Nested If

    FIND is case sensitive. Could that be the problem? If so use the SEARCH function

    Or =IF(ISNUMBER(FIND("MIDDLE",L1,1)),"B",IF(ISNUMBER(FIND("LOWER",L1,1)),"A"))
    Last edited by Pepe Le Mokko; 07-25-2014 at 11:53 AM.

  5. #5
    Forum Contributor
    Join Date
    08-17-2010
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    127

    Re: Trouble with Nested If

    If this works

    =IF(FIND("COST",J12,1)>0,"Found it",IF(FIND("YALL",J12,1)>0,"found it again","havent found it"))

    I don't know why its working, just reconstructed it from 0.

    If it doesn't work - its because it doesn't find what it's looking for - and I don't know how to fix it.
    Last edited by Polymorpher; 07-25-2014 at 11:58 AM.

  6. #6
    Registered User
    Join Date
    07-25-2014
    Location
    Texas
    MS-Off Ver
    2010
    Posts
    4

    Re: Trouble with Nested If

    Thanks for the response. I tried SEARCH and I get the same result.

  7. #7
    Forum Contributor
    Join Date
    08-17-2010
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    127

    Re: Trouble with Nested If

    It crashes on failure to find it. Its either a bug or some god forsaken rule excel has. more likely a rule tough. These kinds of problems I usually solve by running over the help file for the functions that are crashing on me.

  8. #8
    Registered User
    Join Date
    07-25-2014
    Location
    Texas
    MS-Off Ver
    2010
    Posts
    4

    Re: Trouble with Nested If

    There are more than 2 conditions.

  9. #9
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,447

    Re: Trouble with Nested If

    Did you try =IF(ISNUMBER(FIND("MIDDLE",L1)),"B",IF(ISNUMBER(FIND("LOWER",L1)),"A"))

  10. #10
    Forum Contributor
    Join Date
    08-17-2010
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    127

    Re: Trouble with Nested If

    Good, got me of the hook was testing it (:
    And yeah find is case sensitive.
    Last edited by Polymorpher; 07-25-2014 at 12:10 PM.

  11. #11
    Registered User
    Join Date
    07-25-2014
    Location
    Texas
    MS-Off Ver
    2010
    Posts
    4

    Re: Trouble with Nested If

    That worked Pepe!!! Thanks for your help.
    So why does this work and the original formula not work?

  12. #12
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Trouble with Nested If

    Try this..
    A definite solution..

    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Drag it down...

    Don't forget to click *

  13. #13
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,447

    Re: Trouble with Nested If

    Quote Originally Posted by shaught7 View Post
    That worked Pepe!!! Thanks for your help.
    So why does this work and the original formula not work?
    First be aware of how XL compares numbers, text, etc..

    In fact XL first evaluates the value of the TYPE() of both parts of the comparison. ( see XL help for syntax of the TYPE() function) and then the values if both TYPE() functions return the same value.

    So, if FIND finds the string, and returns a number, everything is as should. ( both vales of the TYPE() function are equal, XL then compares the values of the returned number returning TRUE )

    If FIND (or SEARCH) does NOT find the result, it returns an error value #VALUE. As you can see the TYPE() function of an error returns 64 which is larger than the TYPE() value of 0 ( which is 1.
    So, using the FIND function as you did always returns TRUE and the FALSE part is never used ( as you experienced)

    Using the ISNUMBER function to embed FIND we can solve this problem
    Last edited by Pepe Le Mokko; 07-25-2014 at 02:28 PM.

+ 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] Trouble with nested if/and statements
    By NamiSama in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-21-2014, 11:28 AM
  2. Trouble with Nested IF Function
    By gvishnu in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-25-2013, 05:18 PM
  3. Having trouble with nested if commands
    By pmilligan1979 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-11-2012, 02:12 PM
  4. Nested IF statement Trouble
    By mzbhvin in forum Excel General
    Replies: 6
    Last Post: 09-10-2009, 09:10 PM
  5. Trouble with nested IF formula
    By TheRobsterUK in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-04-2005, 10: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