Why not have a column that concatenates ACC and UNQ#, like:-
AAA-1000
AAA-1002
Then when AAA was typed in you would get the two options, then you can use SPLIT to get the UNQ# to do the second vlookup.
By default, vlookup
assumes the data is sorted, and finds the largest element that is less than or equal to the search key. Therefore, you should fill the table with the lower bound for each range:
+-------+--------+-------+---------+
| Minor | Normal | Major | Item |
| 1 | 1 | 1 | Arrow |
| 5 | 11 | 11 | Weapons |
| 10 | 21 | 21 | Potion |
| 45 | 32 | 26 | Ring |
+-------+--------+-------+---------+
Let's say the above is your range B2:E6. The first step is to filter the columns, so that only two are left: one of the first three, and the last one. For this I would use filter
based on regexmatch
:
=filter(B2:E6, regexmatch(B2:E2, "^("&A1&"|Item)$"))
For example, if A1 has "Normal" (my favorite mode) then the regular expression is "^(Normal|Item)$" which matches either of two words, and nothing else. So, if we don't do anything else, the result is
+--------+---------+
| Normal | Item |
| 1 | Arrow |
| 11 | Weapons |
| 21 | Potion |
| 32 | Ring |
+--------+---------+
But of course we don't stop here: the filtered columns should be fed into vlookup
:
=vlookup(A2, filter(B2:E6, regexmatch(B2:E2, "^("&A1&"|Item)$")), 2)
And that is the formula you want. For example, if A2 is 15, then the largest entry that is <=A2 is 11, so the returned value is "Weapons".
Best Answer
your
VLOOKUP
should look something like this: