+ Reply to Thread
Results 1 to 17 of 17

Using multiple cells in VLOOKUP function for lookup_value - possible?

  1. #1
    Forum Contributor
    Join Date
    05-20-2017
    Location
    Boston, US
    MS-Off Ver
    Mac 2011
    Posts
    139

    Using multiple cells in VLOOKUP function for lookup_value - possible?

    Hello!

    I have three consecutive columns (B,C,D) and cells in these columns are filled with values or are empty.
    Column J should display some text based on whether values in cells in columns G,H and I have certain values and those values correspond to a certain condition.

    For example, B2 = 343, C2 = 319, D2 = 200;
    my function should find these values in another sheet, check if the status is "done" for each of them, and put in J13 = "closed".

    For another example, some B6 = 342, C6 = 319, but D6 is empty now, therefore nothing should be displayed in cell J13.

    My basic formula that I am trying to expand is:

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


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


    but it is obviously incorrect as it doesn't check conditions for each cell, doesn't it?

    Please, help me to find a smart solution, preferably based on mathematical approach.
    Thank you very much!
    Attached Files Attached Files
    Last edited by Vitalite; 08-05-2017 at 07:05 AM. Reason: edited the file

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,460

    Re: Using multiple cells in VLOOKUP function for lookup_value - possible?

    As always, please attach a sample workbook.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,460

    Re: Using multiple cells in VLOOKUP function for lookup_value - possible?

    See if this works for you:

    =IF(COUNT(B2:D2)=SUMPRODUCT((B2:D2=sheet2!B2:B4)*(sheet2!C2:C4="done")),"Closed","")

  4. #4
    Forum Contributor
    Join Date
    05-20-2017
    Location
    Boston, US
    MS-Off Ver
    Mac 2011
    Posts
    139

    Re: Using multiple cells in VLOOKUP function for lookup_value - possible?

    Thank you for your help. I am still trying it, but I would like to ask if I correctly understand how the formula works:

    COUNT(B2:D2) gives us the number of columns with numbers; if B2,C2 and D2 are filled with numbers, then COUNT(B2:D2) returns 3;

    B2:D2=sheet2!B2:B4 returns TRUE, namely 1, if the number of columns B2:D2 equals the number of rows sheet2!B2:B4 (otherwise returns FALSE, which is 0); if so, then it can't work in my case - there will be other values in sheet2 B column, not only B2:B4, it is much more extended, and I need to find there values listed in sheet1 B2:D2, and then find if those have "done" status;

    sheet2!C2:C4="done" also returns TRUE if values in all cells C2:C4 are equal "done";

    thus SUMPRODUCT((B2:D2=sheet2!B2:B4)*(sheet2!C2:C4="done")) should return 1, if both conditions are true, or 0, if any is false;

    I don't see how this is evaluated COUNT(B2:D2)=SUMPRODUCT((B2:D2=sheet2!B2:B4)*(sheet2!C2:C4="done")) ?

    Also, what is very important, it seems that this formula accounts only for consecutive values in sheet2, but there might be other values in column B in sheet2, and I need to find in sheet 2 only those listed in B2:D2 in sheet1, and then find if those have "done" status in sheet2. Values might be mixed with other values.
    Last edited by AliGW; 08-05-2017 at 07:58 AM. Reason: Unnecessary quotation removed.

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,460

    Re: Using multiple cells in VLOOKUP function for lookup_value - possible?

    What you really need to do is provide sample data that truly reflects the real data you wish to work with. I have provided a solution based on what you have asked and what has been provided by you. If this doesn't work for you in your real scenario, then redefine the requirement and provide more realistic sample data.

    Unfortunately, I won't be around for much of the day. Hopefully someone else can advise once you've provided the fresh dataset.
    Last edited by AliGW; 08-05-2017 at 07:16 AM.

  6. #6
    Forum Contributor
    Join Date
    05-20-2017
    Location
    Boston, US
    MS-Off Ver
    Mac 2011
    Posts
    139

    Re: Using multiple cells in VLOOKUP function for lookup_value - possible?

    I did provide a refreshed data.
    Also, I am a bit surprised to hear what you say because I myself usually take into account a few possibilities when I look for a solution, and in this case I thought it is obvious that the data can never be so straightforwardly aligned and be in a consecutive list, that there is always a mixture, and I have explained that I need to find those values on sheet2 and only then check their status, and based upon that put value in cell E2 in sheet1.
    Last edited by AliGW; 08-05-2017 at 07:57 AM. Reason: Unnecessary quotation removed.

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,152

    Re: Using multiple cells in VLOOKUP function for lookup_value - possible?

    In E2

    =IF(COUNT($B2:$D2)=SUMPRODUCT(($B2:$D2=sheet2!$B$2:$B$9)*(sheet2!$C$2:$C$9="Done")),"Closed","")

    result "CLOSED"

    in E6

    =IF(COUNT($B6:$D6)=SUMPRODUCT(($B6:$D6=sheet2!$B$13:$B$20)*(sheet2!$C$13:$C$20="Done")),"Closed","")

    Result blank

    Are these the required results?

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,460

    Re: Using multiple cells in VLOOKUP function for lookup_value - possible?

    ... and in this case I thought it is obvious that the data can never be so straightforwardly aligned and be in a consecutive list, ...
    Obvious to you, of course, but how could I have known without guessing? There is nothing in your original post that suggests that the sample data might not be truly representative. I could have made all sorts of assumptions, but that can be dangerous in itself, which is why we specifically ask for sample data to be representative of the real data involved.

    ... and I have explained that I need to find those values on sheet2 and only then check their status, and based upon that put value in cell E2 in sheet1 ...
    Yes, and based on the sample data, that is what the formula I gave to you does.

    Anyway, I have to go out now.

    PS I see you edited your opening post AFTER I provided my solution, with a dataset that differs siginificantly, but you did not tell us that you had done so. I don't as a matter of course keep checking original posts for updates, in fact if you are changing the sample data, it is much better to provide the new file at the approriate point in the thread, otherwise it just gets confusing for everyone trying to help. It also makes it appear as if my original suggestion was completely wrong, which it was not based on the original data. If you sense a hint of frustration in what I am typing, then you are right.
    Last edited by AliGW; 08-05-2017 at 07:59 AM.

  9. #9
    Forum Contributor
    Join Date
    05-20-2017
    Location
    Boston, US
    MS-Off Ver
    Mac 2011
    Posts
    139

    Re: Using multiple cells in VLOOKUP function for lookup_value - possible?

    I am sorry! I should have written a note about the edit. When I edited the post, I thought about putting a special EDIT word inside the text, but then I noticed the Reason of your edit box, and filled it. Yes, didn't take into account that people not necessarily check the original post. Sorry once again!
    Last edited by AliGW; 08-05-2017 at 09:02 AM. Reason: Unnecessary quotation removed.

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,460

    Re: Using multiple cells in VLOOKUP function for lookup_value - possible?

    OK, so please now respond to John's query in post #7.

    And, not for the first time, could I plead with you not to quote unnecessarily? Don't quote whole posts, especially when you are responding to the one immediately preceding your own - it's just clutter. It's OK to quote if you are responding to a post out of sequence, but limit quoted content to a few relevant lines that makes clear to whom and what you are responding (e.g. my last post to you). Thanks!

    For normal conversational replies, try using the QUICK REPLY box below.

  11. #11
    Forum Contributor
    Join Date
    05-20-2017
    Location
    Boston, US
    MS-Off Ver
    Mac 2011
    Posts
    139

    Re: Using multiple cells in VLOOKUP function for lookup_value - possible?

    Quote Originally Posted by AliGW View Post
    OK, so please now respond to John's query in post #7.
    I will respond to John's query, of course, once I try it, and see how it works. But you have not responded to my questions about parts of the formula.

    I would like to also ask you for a huge favor: I believe that it is better to state some request only once. It usually enough for a person to get your message. )

  12. #12
    Forum Contributor
    Join Date
    05-20-2017
    Location
    Boston, US
    MS-Off Ver
    Mac 2011
    Posts
    139

    Re: Using multiple cells in VLOOKUP function for lookup_value - possible?

    Quote Originally Posted by JohnTopley View Post
    In E2

    =IF(COUNT($B2:$D2)=SUMPRODUCT(($B2:$D2=sheet2!$B$2:$B$9)*(sheet2!$C$2:$C$9="Done")),"Closed","")

    result "CLOSED"

    in E6

    =IF(COUNT($B6:$D6)=SUMPRODUCT(($B6:$D6=sheet2!$B$13:$B$20)*(sheet2!$C$13:$C$20="Done")),"Closed","")

    Result blank

    Are these the required results?
    Yes, these are the results. There are two issues though:
    1) I still don't see how this formula works, and I have asked questions about each part of it;
    2) maybe because of the above, it doesn't work when I have a more extended data set, and when columns in sheet2 are far apart: column I have task numbers and column R contains "done", or none, conditions; even if on sheet1 only one cell is filled with a value, and two other cells are empty, I still get Closed.

  13. #13
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,152

    Re: Using multiple cells in VLOOKUP function for lookup_value - possible?

    Yet again, despite numerous requests, you post files which are not representative of your TRUE file: you reference Column R in your reply above but your posted files have data in B & C.

    As Ali pointed out earlier, we are not mind readers and unless you feel experienced enough to translate "examples" into you real data, then post sample files which exactly mirror your real file.: again, Ali requested that you do this.

  14. #14
    Forum Contributor
    Join Date
    05-20-2017
    Location
    Boston, US
    MS-Off Ver
    Mac 2011
    Posts
    139

    Re: Using multiple cells in VLOOKUP function for lookup_value - possible?

    I didn't require you to become mind readers, and I simply mentioned the fact that it doesn't work other circumstances, and to understand why I need to understand the formula. I asked specific questions about the formula because I never copy anything mindlessly, but come here to learn from you - you are professionals, and know much more& But my questions were simply ignored, and instead I got a few lines of what I do wrong when posting here.
    Last edited by Vitalite; 08-05-2017 at 10:19 AM. Reason: Unnecessary quotation removed.

  15. #15
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,460

    Re: Using multiple cells in VLOOKUP function for lookup_value - possible?

    I never copy anything mindlessly, ...
    This is a good thing! However, you will learn more effectively if you do things in the way we have advised, instead of the way that you think is correct and is becoming the cause of considerable frustration. Believe it or not, we ARE trying to help you!

    Many of us here are not professionals when it comes to Excel: both John and I are self-taught, and that has been over a period of many years through fora like this one and other means, including trial and error. I have been given formulae that it has taken me a significant time to fully understand, indeed I am able to offer help here using complex formulae that I cannot myself fully explain, in some cases, so your insistance on understanding every aspect of the formula, whilst perfectly admirable, is actually holding you back.

    Once we have got to the bottom of what you are actually trying to do with this formula then we can tell you what it does, how it does it and what you need to do to adapt it.

    What you can then do, in your own time, is practise adapting formulae bit by bit: the evaluate formula feature on the formula ribbon is partcularly useful for this.
    Last edited by AliGW; 08-05-2017 at 10:25 AM.

  16. #16
    Forum Contributor
    Join Date
    05-20-2017
    Location
    Boston, US
    MS-Off Ver
    Mac 2011
    Posts
    139

    Re: Using multiple cells in VLOOKUP function for lookup_value - possible?

    Thank you very much. I know that you are truly trying to help, and I do appreciate it a lot - no words can express my gratitude; I have already learned a lot thanks to answers I get here. It's just the way I am, I do need to understand each part of any solution; this is the way I learn, and it does work for me based on my experience. So, please, if you have a bit of time, read my post where I try to explain how I read your formula. I believe I do read some parts of it incorrectly.

  17. #17
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,460

    Re: Using multiple cells in VLOOKUP function for lookup_value - possible?

    Here's what it's doing:

    =IF(COUNT(B2:D2)
    COUNT works with numbers in an array - it counts non-blank cells that contain a number - here, there are 3.

    =SUMPRODUCT((B2:D2=sheet2!B2:B4)*(sheet2!C2:C4="done")),
    This section gets Excel to generate an array of TRUE and FALSE values which resolve to 1s and 0s - there are 3 matches in this array where one of the numbers in our count array matches a number in the lookup array that has "done" next to it.

    "Closed","")
    Excel returns "Closed" because there are the correct number of matches in the array. Where there are not, it will return blank ("").
    Last edited by AliGW; 08-05-2017 at 10:49 AM.

+ 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. Help? vlookup multiple lookup_value is this possible?
    By freedert001 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-30-2016, 01:50 AM
  2. using vlookup where lookup_value is a formula
    By foozbear in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-15-2015, 01:55 AM
  3. 2 lookup_Value for Vlookup
    By bryceismad1 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-29-2014, 02:06 PM
  4. [SOLVED] VLookup if lookup_value is not found
    By jndipworm in forum Excel General
    Replies: 4
    Last Post: 07-09-2012, 06:47 PM
  5. VLOOKUP won't take a formula for lookup_value???
    By scurveydog in forum Excel General
    Replies: 3
    Last Post: 10-05-2010, 05:21 PM
  6. lookup_value in VLOOKUP formula
    By 99f150 in forum Excel General
    Replies: 7
    Last Post: 03-16-2010, 11:21 AM
  7. vlookup:same lookup_value, different returns
    By javino in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-15-2005, 09:00 PM

Tags for this Thread

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