4

I have the following tables in Excel:

Product Stock

and

Stock Analysis.

The product Stock table (PST) is more extensive than this but for the purposes of this question I have cut it down.

I want to lookup the value in a column in Stock Analysis table (SAT) matches the value in the Size column of the Product Stock table.

For example, in this case, the value in the Size Column of my Product Stock table (PST) is 8 so I want to look up the value in the Size 8 column of my Stock Analysis table. If my value were 5 then lookup Size 5 in my Stock Analysis table (SAT).

Note that data validation has been carried out to ensure that the values in the Size column of my Product Stock table are based on specified dimension hence will only have a range of sizes that are also the columns of the Stock Analysis table

Also formula has been inserted to ensure that the next row of the SAT will always have a batch number which is one more greater than the previous row (i.e. there is increase of 1 on the Batch No column for each new row) this is to ensure no repetition of batches in the SAT

What I have so far is:

=IF(PST[Batch No]=SAT[Batch No, VLOOKUP(PST[Batch No], PST, Stuck here, FALSE), "")

What I need on the col_index_num is to match the value in my Size column of my PST to the last character of the string in the headers of SAT excluding the Batch No header (this might not affect it though). When there is a match give the column number on the table.

This will then give the value under that column that matches the Batch No.

I hope this is fairly understandable.

I would very much not like to delve into VBA

2
  • Not sure I completely understand. You have not labeled your tables, I assume the first is your PST and second is your SAT? Also, what result are you expecting? You mention the size column of your PST is 8, what would the result be from your SAT table? I assume 7? Commented May 2, 2017 at 10:48
  • 1
    Yes, I apologize but when I was typing the question it seemed to me that the tables were labeled. I, however, tried to explain further. @g.kov seemed to have solved my problem.
    – MrMarho
    Commented May 2, 2017 at 12:05

2 Answers 2

10

Something like this?

enter image description here

Formula in H12 is:

=VLOOKUP(E12,$C$6:$H$8,MATCH("Size "&F12,$C$5:$H$5,0),FALSE)

Edit: How the formula in H12 works.

The part that provides a column number,

MATCH("Size "&F12,$C$5:$H$5,0)

first concatenates the prefix "Size " with the value of F12 (=8), resulting in a string "Size 8". Then it looks through the cells in the header row $C$5:$H$5 to find this key string and returns a number of the matching cell, namely, 6 (the last cell in the header). Then the formula

=VLOOKUP(E12,$C$6:$H$8,MATCH("Size "&F12,$C$5:$H$5,0),FALSE)

essentially becomes

=VLOOKUP(E12,$C$6:$H$8,6,FALSE)

which looks for the content of E12 (=1) in the first column of the range $C$6:$H$8. In other words, it selects the row, that corresponds to Batch No=1, which is 1. And given the row (=1) and column (=6) numbers in the range $C$6:$H$8, VLOOKUP returns a value stored in H6, which is 7.

4
  • Yes exactly what I'm looking for. You just ended 4 hours of brainstorming.
    – MrMarho
    Commented May 2, 2017 at 11:59
  • So there's no need for my IF function since data validation has been carried out I presume?
    – MrMarho
    Commented May 2, 2017 at 12:06
  • 2
    @MrMarho: Well, there is always a place for errors, so it's up to you how to handle them.
    – g.kov
    Commented May 2, 2017 at 13:13
  • @fixer1234: added
    – g.kov
    Commented May 2, 2017 at 20:17
2

Try the index function with a match for the Batch# and the Size text:

=INDEX(C6:H8,MATCH($E12,$C$6:$C$8,0),MATCH("Size "&$F12,$C$5:$H$5,0))
1
  • 3
    Welcome to Super User. Answers that educate are better than ones that just provide a cut and past solution because they help the reader understand how to solve the next problem. Can you add a couple of sentences to explain how this works? Thanks.
    – fixer1234
    Commented May 2, 2017 at 19:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .