+ Reply to Thread
Results 1 to 13 of 13

Nested IF ordering issue

  1. #1
    Registered User
    Join Date
    05-07-2012
    Location
    Pensacola, Fl
    MS-Off Ver
    Excel 2007
    Posts
    6

    Nested IF ordering issue

    Can't figure out what is wrong with this formula.

    What I need it to do:
    Look in cell C2. If C2 contains the letters "abc" anywhere in the string then 0 is the result.
    If c2 does not contain "abc" then, use lookup this table on worksheet named "data" the result is the second column.

    =IF(C2 = "*abc*", 0, IF(ISNA(VLOOKUP(I4, Data!$E$2:$F$13, 2)),0, VLOOKUP(I4, Data!$E$2:$F$13,2,)))

    The problem I am having is in the first part of the formula...when I evaluate the formula, c2 is evaluating as false when "abc" or "abcdef" is the value of c2.

    Any suggestions? Thanks.
    Last edited by dilly; 05-08-2012 at 07:45 AM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,730

    Re: help on excel formula

    Try including the match function in the first part. Look here:

    http://www.techonthenet.com/excel/formulas/match.php

    Alan
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    05-07-2012
    Location
    Pensacola, Fl
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: help on excel formula

    Thanks, but that is not quite working. The first part of the formula, (c2 = "*abc*", 0), I am just checking one cell for these letters and if they are in that cell I need a value of 0 returned. The Match function seems to be useful for an array which I don't have here and I need a specific value returned (0).

  4. #4
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,366

    Re: help on excel formula

    this is not the best but you can start with it..

    =IF(C2=IFERROR(SEARCH("*abc*",C2,1),0),0,IFERROR(INDEX(E2:F13,MATCH(I4,E2:E13,0),2),0))
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,730

    Re: help on excel formula

    ok. I understand. Try this

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    05-07-2012
    Location
    Pensacola, Fl
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: help on excel formula

    vlady, Not sure I follow all your logic but the end result is that this doesn't give me the answer I am looking for. Maybe a better explanation of what I am trying to do would help. I have a table set up on a separate worksheet of this workbook. The first column is a list of names the second column is a rate of pay. I need to list the rate of pay based on which name is selected from the first column. That is the second part of my formula and seems to work ok by itself. The hitch is in the first part of the formula. This part trumps the second part, if c2 has "abc" anywhere in that cell then the rate of pay becomes 0.
    Last edited by dilly; 05-07-2012 at 10:31 PM.

  7. #7
    Registered User
    Join Date
    05-07-2012
    Location
    Pensacola, Fl
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: help on excel formula

    Alan, Almost there, The first part evulates ok if "abc" exists, however if "abc" doesn't exist then I get #VALUE. If "abc" doesn't exists then I need to use the second part to determine the rate.

  8. #8
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,730

    Re: help on excel formula

    With out seeing your data or a sampling of your data, it is difficult to take this any further. Suggest you dummy up a workbook (remove confidential information) and upload a workbook so that someone here can take a detailed look at what you are doing.

  9. #9
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,366

    Re: help on excel formula

    =IF(IFERROR(SEARCH("*abc*",C2,1),0),0,IFERROR(INDEX(E2:F13,MATCH(I4,E2:E13,0),2),0))

  10. #10
    Registered User
    Join Date
    05-07-2012
    Location
    Pensacola, Fl
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: help on excel formula

    Worksheet 1:
    ....|C|........I|J //columns
    2...|abcdef|...bob|rate here|
    3...|abc123|...joe|rate here|
    4...|xyz|......tom|rate here|

    Worksheet "data"
    Table
    ...E|F|...
    ...joe|10
    ...bob|10
    ...barb|10
    ...jill|0
    ...tom|0

    Hopefully to save those who don't want to open an attachment a quick ref above otherwise a sample worksheet is attached.

    Here is what is going on:
    For worksheet 1, column J, in each row I need to look at column C. If in Column C the data starts with "abc" (it can more text than just abc but must contain the abc), then the rate in column J is going to be 0 regardless of any other info in column I. If column C does not start with "abc", then I need to look up the name selected(from a drop down list) in column I and the result for column J is the applicable rate for that person. The dropdown list is located on Worksheet called "data" located within the same workbook. The list/table spans E2:F13 of the worksheet.

    I started with this:
    =IF(C2 = "*abc*", 0, IF(ISNA(VLOOKUP(I3, Data!$E$2:$F$13, 2)),0, VLOOKUP(I3, Data!$E$2:$F$13,2,)))
    This did not work because C2 evaluated as false with data such as, "abcdef" Not sure if the entire statement would work if I got the first part to work.

    Now I am here:
    =IF(FIND("Intro",C5),0,IF(ISNA(VLOOKUP(I5,Data!$E$2:$F$13,2)),0,VLOOKUP(I5,Data!$E$2:$F$13,2,)))

    So, Alan suggestion of using find almost works, but if "abc" is not found I get a return value of #VALUE in column J. The ordering of the IFs (I am guessing) is causing the first if to be evaluated but the second part of the formula is not being evaluated.

    I have also tried reversing the If order, but I get an error of "too many arguments"
    =IF(ISNA(VLOOKUP(I9,data!$E$2:$F$13,2)),0,VLOOKUP(I9,data!$E$2:$F$13,2,), IF(FIND("abc",C9),0))

    uuuugh! Any suggestions?example.xlsx

  11. #11
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Nested IF ordering issue

    In cell J2 and copied down:

    =IF(COUNTIF(C2,"*abc*"),0,IFERROR(VLOOKUP(I2,data!$F$2:$G$13,2,0),0))

    BUT - this gives a result of 0 in J4 which you say is not correct, that it should be 10. Why?? C4 is "abcxyz" so that should produce 0 according to your request.
    All other cells match what you say should be the result.

    BTW - your VLOOKUP()s were searching E:F when they should be searching F:G (as used in the formula I have suggested)
    Last edited by Cutter; 05-08-2012 at 09:22 AM.

  12. #12
    Registered User
    Join Date
    05-07-2012
    Location
    Pensacola, Fl
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Nested IF ordering issue

    Sorry about the typos. I was copying from the actual spreadsheet to an example sheet and slid over a column..... and yes it should be 10.

    Ahh, yes...this is working. I will run it through some more and make sure I have what I need. But I think this is the ticket.

    Many thanks to all. Dilly

  13. #13
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Nested IF ordering issue

    You're welcome. Thanks for the 'star tap' and thanks for marking your thread SOLVED.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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