
Originally Posted by
6StringJazzer
Welcome to the Forum!
Put this formula in B12 and copy down through the yellow cells:
=HLOOKUP(B$10,Sheet2!$A$1:$K$31,ROW()-ROW(Sheet1!B$12)+2,FALSE)&""
Here is how it breaks down.
HLOOKUP will look across a row for a match of a particular value, and then return the value a specified number of rows beneath the value it found. The function is of this format:
HLOOKUP(value, range, relative row [, nearest match])
value is the value you are looking for in the first row
range is the range of cell in which you are searching (1 means the first row, which contains value, so you usually are going to use a number >1)
relative row is the row within the range containing the value you want the function to return
nearest match is TRUE if the data is sorted and you want the highest match at or below what you are searching for, FALSE if you require an exact match
The value is the value in the dropdown box. The range is the entire range of cells on Sheet2 that you are searching. To count down the correct number for relative row, you want to take the row number of the cell containing the formula minus the first cell containing a formula, then add 2. A little study will show you why the arithmetic works that way. For nearest match you require an exact match.
After all that, we append a null string at the end
&""
If the cell found is blank, it will be interpreted as a 0 and you'll see a 0 in the cell with the formula. If you append a null string to it, it forces Excel to treat it as a string and you will get a blank cell as a result.
Bookmarks