I'm trying to create a matrix where I can look up a value based on length of parts, diameter, and production hours. I've attached a sample of what I'm looking to do.
Columns M, N, & O are the variables I need to look up in the grid to the left. I need to find the match and then put that in column P.
I entered the first one in column P as an example. Book2.xlsx
For a lookup like this you should really normalize your data. You should have columns hours, min dia, max dia, min length, max length, and work center. That's your "database". At that point it becomes much easier to do multiple criteria searches on your data. You can use a pivot table at that point too. Do some googling for sumproduct lookups and you'll find a wealth if info.
You need to watch out for pieces that are too thin or too thick for the limits in the table. The suggested formula handles the minimum constraint, but not the maximum. It needs another two rows of data in the lookup table for that feature.
Using VLOOKUP and MATCH, here is an alternative approach. You will need to refer to the sample workbook to understand the cell range references.
=IF(N2<40,VLOOKUP(O2,E$3:K$8,MATCH(M2,G$2:K$2)+2),VLOOKUP(O2,E$10:K$13,MATCH(M2,G$2:K$2)+2))
Lawrence SalvucciInformation Technology ManagerAuthor Commented:
@barryhoudini
I made a mistake on my sample file. If the production hours are greater than 40 but not in those 2 size ranges then it needs to look at the other 4 ranges and find the work center. The top 4 ranges should not be less than 40 hours. Those 4 ranges are for any amount of hours and only if the hours are greater than 40 and within those 2 ranges at the bottom should it look for the work center there. I hope this makes sense. I attached a new sample file with your formulas. Sample-File.xls
Using the latest sample workbook, you might use a formula like:
=INDEX(G$17:K$23,IF(AND(N2>40,O2<F$23),MATCH(O2,E$22:E$23),MATCH(O2,E$17:E$20)),MATCH(M2,G$16:K$16))
Lawrence SalvucciInformation Technology ManagerAuthor Commented:
I don't believe it's working properly with either of those formulas. If you look at the one I highlighted in orange you will see why. Copy-of-Sample-File.xls
For your problem situation, I needed to check the minimum thickness condition as well. I therefore suggest this revised formula:
=INDEX(G$17:K$23,IF(AND(N2>40,O2<=F$23,O2>=E$22),MATCH(O2,E$22:E$23)+5,MATCH(O2,E$17:E$20)),MATCH(M2,G$16:K$16))
The +5 in this formula shifts to the bottom part of the table, and I mistakenly left it out of my previously suggested formula. It is necessary, as you can see with inputs 67, 44 and .0625 (original formula returned 2051 but should have returned 2053-1).
I put in a new table in E16:K23 then you can use this formula in P2 copied down
=IF(N2>40,INDEX(G$22:K$23,
You get #N/A error in P13 because size doesn't fall in any of the ranges
see attached
regards, barry
27323353.xlsx