Hey all,
I just recently figured out the VLOOKUP function and have been putting it to good use. My question is how do I return an entry when I don't have anything acting as a key. In most cases I can use a lot number for this, but we have a few lot numbers that are used by two or more of our clients at once. Is there a way to call in an entry based on two "lookup values' as the VLOOKUP formula calls it. I have a hunch I may be getting into array territory with this, but I'm not sure. Thanks!
Last edited by bibleguy125; 08-29-2011 at 10:52 AM.
You can do it a few ways.
Easiest would be to Concatenate the 2 table columns to search in, and place that concatenated column to the left of the columns to return,
Then you can use Vlookup..
e.g.
=VLOOKUP(A1&"_"&B1,'Sheet2'!$C$1:$D$100,2,FALSE)
where A1 and B1 are the fields you want to combine for the search.
And Sheet2!C1:C100 contains the concatenated columns, of say columns A and B separated with an underscore to ensure robustness of the search.
e.g. =A1&"_"&B1 copied down
And then column D will be the column to return results from.
Another way is with no concatenation.
=INDEX(Sheet2!D1:D100,MATCH(1,INDEX((Sheet2!A1:A100=A1)*(Sheet2!B1:B100=B1),0),0))
this searches A1:A100 for a match to A1 on current sheet as well as searching B1:B100 on Sheet2 for B1 match, and returns what is in corresponding row of column D.
Microsoft MVP - Excel
Where there is a will there are many ways. Pick One!
Please read the Forum Rules
If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below
Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Preferred Charities: Lupus Canada and Sick Kids Foundation.
Feel Free to Donate if you want to, for the assistance you received today.
That sounds like exactly what I need, I guess I'm not sure what you mean by this though. I won't have my two variables in the same columns as the master sheet if that matters. I have attached an example of what I want the finished product to look like. Do you mean that a column on the master sheet would need to be combined into one cell to be used as a key?
Where is the database sheet with all the companies, lots and variables you want to pull over? And where in the master sheet is the information supposed to go?
Microsoft MVP - Excel
Where there is a will there are many ways. Pick One!
Please read the Forum Rules
If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below
Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Preferred Charities: Lupus Canada and Sick Kids Foundation.
Feel Free to Donate if you want to, for the assistance you received today.
Here is just a basic example. The lot and company go where indicated and is what I want to use as the search parameters. I just need to figure out how to use the two search parameters with VLOOKUP. With what you were saying before, do I need to insert a column before A on the database sheet and combine the company column and the lot column to make a unique key? Thanks a lot!
I tried what I was talking about and it seems to work. Is this what you were talking about, or is there a better way that I'm missing?
See attached for the suggestion,
Inserted a new column before column A on the Master sheet, and inserted formula:
=B2&"_"&H2
copied down.
Then in the Output sheet, you enter the company and lot Id's, and formula, for example in B3 is:
=IF(G3="","",VLOOKUP($F$1&"_"&G3,'Master-Database'!$A:$T,3,FALSE))
copied down.
For the other columns, you need the same formula and just change the 3 to the respective corresponding column number in the Master table.
Microsoft MVP - Excel
Where there is a will there are many ways. Pick One!
Please read the Forum Rules
If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below
Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Preferred Charities: Lupus Canada and Sick Kids Foundation.
Feel Free to Donate if you want to, for the assistance you received today.
Thanks NBVC, that is what I needed. You are a big help.
Last edited by NBVC; 08-29-2011 at 11:13 AM. Reason: corrected spelling of my name
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks