First let's look at INDEX. INDEX requires three arguments
=INDEX(data range, row number, column number). In the table below our data range would be A1:F13. If we entered =INDEX(A1:F13,7,4) the function would return My HD since that is the value in Row 7 and Column 4. To become a useful function we need to be able to change the Row argument without typing in a different number. To do this we use the MATCH function
The MATCH function also requires three arguments
=MATCH(value, single column data range, match type) where value is the value being searched for, data range is the column containing the value being searched for, match type is either 0 for exact match, 1 for less than or -1 for greater than. In the above table =MATCH("BCM",C1:C13,0) would return 8. This is the row number where BCM is found.
When we combine the two functions we can return data to either the left or the right of the search value. If we enter =INDEX(A1:F13,MATCH("LMP",C1:C13,0),2) in cell J4 the function will return 201 which is the Branch Number for Leona.
One more step and we have a useful user function. Instead of typing "LMP" in the formula we reference a cell, in this case we'll use J2. Now we have the following formula:
=INDEX(A1:F13,MATCH(J2,C1:C13,0),2). When the value in cell J2 is changed the Branch Number corresponding to that Sales ID will display.
No comments:
Post a Comment