# Thread: Compare cell to a range or table

1. ## Compare cell to a range or table

I am trying to look at a cell value, find it in a A and B column of range.

A1=24
a2=10 B2-19 c2=A
a3=20 B3= 29 B3=B
A4=30 b4=39 c4=C

I want to look up A1, find which range it is, and return whatever in in the corresponding C cell. In this example, a "B" would be returned to Cell D1.Compare Formula.xlsx  Reply With Quote

2. I used what you have in your post for my solution. I believe you post is different from the worksheet you submitted.

So in cell D1 I would have the following formula:

IF(AND(A1>=A2,A1<=B2),"A",IF(AND(A1>=A3,A1<=B3),"B",IF(AND(A1>=A4,A1<=B4),"C","error")))

Please test it thoroughly. I've never been fond of nested if formulas.  Reply With Quote

3. Another option
=INDEX(C3:C6,MATCH(A1,A3:A6,1))  Reply With Quote

4. =lookup(a1,a3:a6,c3:c6)  Reply With Quote

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•