# IF Function Question

##### New Member
I have a column with numbers in it. Each of these numbers I want to logically test to the following statement:
IF > 21 AND < 180 THEN YES otherwise NO for example. So in other words I want to know if the number in my column is between 21 and 180. I know I have to use an IF statement but I do not know how to combine the 2 conditions into one formula.

Can anyone help? Thanks in advance!

### Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a \$25,000 loan, 5% annual interest, 60 month loan.

#### Gerald Higgins

##### Well-known Member
Code:
``=if(and(a1>21,a1<180),"YES","NO")``

#### Joe4

Use IF and AND. Let's say you are testing the value in cell A1, then use:

=IF(AND(A1>21,A1<180),"Yes","No")

#### DiscoPistol

##### Active Member
=IF(AND(A1>21,A1<180),"Yes","No")

DP

#### DiscoPistol

##### Active Member
I need to learn to type faster........

#### barry houdini

##### MrExcel MVP
You could also return TRUE or FALSE with the shorter

=(A1>21)*(A1<180)

Replies
3
Views
311
Replies
4
Views
90
Replies
3
Views
96
Replies
1
Views
170
Replies
9
Views
92

1,181,102
Messages
5,928,062
Members
436,586
Latest member
latintxn

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back