I have two separate tables in an Excel worksheet, as illustrated below.
Columns A
, B
, E
, F
and G
are my input values;
I want a formula that generates the values in Column C
(shown in italics):
A | B | C | D | E | F | G | |
---|---|---|---|---|---|---|---|
1 | Name | Value | Type | Type | Lower | Upper | |
2 | Andy | 35 | Spam | Spam | 35 | 39 | |
3 | Mark | 85 | Foo | Ham | 25 | 27 | |
4 | Pat | 28 | N/A | Eggs | 91 | 95 | |
5 | Deb | 93 | Eggs | Foo | 82 | 86 | |
6 | Emily | 92 | Eggs | Bar | 65 | 69 | |
7 | Greg | 22 | N/A | ||||
8 | Gary | 67 | Bar |
For each row in the first table (i.e., each person),
I want to find that person’s Type based on their Value (Column B
)
by finding the row in the second table where the person’s Value
falls within the Lower→Upper range (Columns F
and G
).
So, for example, Mark (Row 3) has a Type of “Foo”
because his Value (85) falls between 82 and 86,
associated with “Foo” in Row 5 of the second table.
Note that Pat’s Value is 28 (Row 4), which does not match any range.
The ranges are inclusive.
For example, Andy’s Type is “Spam” (Row 2) even though his Value (35)
equals the Lower end of the range for “Spam” (Cell F2
).
I know nested IFs are quite hard to debug in Excel, so I’d like to avoid that if possible.