+ Reply to Thread
Results 1 to 12 of 12

INDEX MATCH or VLOOKUP formula based on a condition

Hybrid View

  1. #1
    Registered User
    Join Date
    10-05-2014
    Location
    denver
    MS-Off Ver
    8
    Posts
    13

    INDEX MATCH or VLOOKUP formula based on a condition

    Dear all,
    I have tried to google internet and search this board without any success.
    I have two tabs: Tab A and Tab B.
    I need to look up a Code for the Tab A using "Item #" which is also available in TAB B. However, the problem is that in the Tab B there are usually few rows with the same "Item #" and sometimes they do not have "Code" numbers. That is why VLOOKUP does not work.
    I need to find the Code number for the "Item#" with a condition that "Resource" in Tab B has a value " Labor" or "Admin Labor". Because usually the rows which have Resource as "Labor " or "Admin Labor" have Code specified.

    thank you
    Attached Files Attached Files

  2. #2
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: INDEX MATCH or VLOOKUP formula based on a condition

    Enter this array formula in C3 and copy down
    Formula: copy to clipboard
    =IFERROR(INDEX('Tab B'!D:D,SMALL(IF(('Tab B'!B$3:B$10=B3)*('Tab B'!$D$3:$D$10<>""),ROW('Tab B'!B$3:D$10)),ROWS(C$3:C3))),"")

    ***Array formula
    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER.
    You will know the array is active when you see curly braces { } appear around your formula.
    If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    Or try this non array version
    Formula: copy to clipboard
    =IFERROR(INDEX('Tab B'!D$3:D$10,INDEX(MATCH(1,('Tab B'!B$3:B$10=B3)*('Tab B'!D$3:D$10<>""),0),0)),"")
    Last edited by AlKey; 09-14-2016 at 04:26 PM.
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  3. #3
    Registered User
    Join Date
    10-05-2014
    Location
    denver
    MS-Off Ver
    8
    Posts
    13

    Re: INDEX MATCH or VLOOKUP formula based on a condition

    I have not tried second formula. I will try it in a few minutes.

  4. #4
    Registered User
    Join Date
    10-05-2014
    Location
    denver
    MS-Off Ver
    8
    Posts
    13

    Re: INDEX MATCH or VLOOKUP formula based on a condition

    AlKey,
    thank you so much for a quick reply. Do you mind quickly explaining what SMALL and ROWS mean because i am trying to copy this formula to my larger set of data and it works for some rows but not for all.
    Also in the end is it supposed to be ROWS(C$3:C3) or ROWS(C$3:C$3)?
    Also i really would like somehow to insert the Condition that Column Resource in Tab B is either "Labor" or "Admin Labor" because there are many other rows with the same Item # but different Resources and they have wrong Codes. I only need Codes which are for Labor and Admin Labor Resources.

  5. #5
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: INDEX MATCH or VLOOKUP formula based on a condition

    The ROWS part should be exactly as written ROWS(C$3:C3)
    For other details of an array formula please follow the link below.

    http://www.exceltactics.com/make-fil...using-small/4/

  6. #6
    Registered User
    Join Date
    10-05-2014
    Location
    denver
    MS-Off Ver
    8
    Posts
    13

    Re: INDEX MATCH or VLOOKUP formula based on a condition

    I have made some progress but I was not able to completely resolve the problem...
    I have read about the "INDEX SMALL IF ROW ROWS" function but for some reason it did not work for my table.

    I have tried INDEX MATCH =IFERROR(INDEX('Tab B'!D$3:D$10,INDEX(MATCH(1,('Tab B'!B$3:B$10=B3)*('Tab B'!D$3:D$10<>""),0),0)),"")
    and it worked better.
    However, INDEX MATCH made few mistakes. Like I mentioned before there are some rows when I have
    multiple Code numbers. And I only need to pick ones which are corresponding to the Resource "Labor" or "Admin Labor"
    in the original table.
    I am attaching the updated file so you can see. When use the formula it picks up Code R560 for the first row but has to pick up one which
    is for the "Labor" Resource, A001.
    hope it makes sense.
    Attached Files Attached Files

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: INDEX MATCH or VLOOKUP formula based on a condition

    This will work in C3, copied down:

    =IFERROR(INDEX('Tab B'!D$3:D$10,(MATCH(1,('Tab B'!$A$3:$A$10='Tab A'!A3)*('Tab B'!$B$3:$B$10='Tab A'!B3)*(IF(ISERROR(SEARCH("Labor",'Tab B'!$C$3:$C$10)),FALSE,TRUE)),0))),"")
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: INDEX MATCH or VLOOKUP formula based on a condition

    Oops. It's an array formula, BtW.

    Array Formulae are a little different from ordinary formulas in that they MUST be confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER.

    You will know the array is active when you see curly braces { } appear around the outside of your formula. If you do not CTRL+SHIFT+ENTER you will (almost always) get an error message or an incorrect answer. Press F2 on that cell and try again.

    Don't type the curly braces yourself - it won't work...

  9. #9
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: INDEX MATCH or VLOOKUP formula based on a condition

    Try this
    Formula: copy to clipboard
    =IFERROR(INDEX('Tab B'!D:D,SMALL(IF((ISNUMBER(SEARCH("labor",'Tab B'!C$3:C$10)))*('Tab B'!B$3:B$10=B3),ROW('Tab B'!B$3:C$10)),1)),"")

    ***Array formula
    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER.
    You will know the array is active when you see curly braces { } appear around your formula.
    If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    And with regular
    Formula: copy to clipboard
    =IFERROR(INDEX('Tab B'!D$3:D$10,INDEX(MATCH(1,('Tab B'!$B$3:$B$10=B3)*INDEX(ISNUMBER(SEARCH("Labor",'Tab B'!$C$3:$C$10)),),),)),"")
    Attached Files Attached Files
    Last edited by AlKey; 09-15-2016 at 08:22 AM. Reason: Added Excel spreadsheet

  10. #10
    Registered User
    Join Date
    10-05-2014
    Location
    denver
    MS-Off Ver
    8
    Posts
    13

    Re: INDEX MATCH or VLOOKUP formula based on a condition

    ALKey, thank you for your assistance.
    I tried the second INDEX MATCH formula with SEARCH. It works only for the rows which have "Labor" but not for "Admin Labor". If i could only add OR somehow. Labor or Admin Labor.

  11. #11
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: INDEX MATCH or VLOOKUP formula based on a condition

    Actually, both formulas pick up "Labor" and "Admin Labor". This is why I used SEARCH function so it will look for any text string that contain word "labor" and this is evident from the post #9 (see attached file). As a test, replace word "labor" in the formula with "Admin Labor" and you will see that both formulas will not pick up the first code they will pick up the second code only.

    Regards,

  12. #12
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: INDEX MATCH or VLOOKUP formula based on a condition

    Apple_tree. Did you actually open the sheets posted by Alkey (#9) and myself (#7) Did the formulae do what you wanted?

+ 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: 8
    Last Post: 03-17-2016, 08:14 PM
  2. Replies: 6
    Last Post: 03-06-2015, 03:20 PM
  3. Index and Match with based on IF then condition?
    By aglander in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-08-2014, 05:59 PM
  4. [SOLVED] Vlookup (IFS) 3 Condition Model Using Index /Match
    By Winship in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-28-2014, 07:06 PM
  5. Replies: 4
    Last Post: 01-13-2014, 04:16 AM
  6. [SOLVED] Conditional formatting based on VLOOKUP/INDEX:MATCH
    By strud in forum Excel General
    Replies: 2
    Last Post: 06-13-2013, 07:02 AM
  7. INDEX/MATCH & VLOOKUP based on month number
    By pixifaery in forum Excel General
    Replies: 2
    Last Post: 07-08-2010, 06:48 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