# Need help with IF statement

#### Barry Katcher

##### Well-known Member
In cell A1, I have a 4 digit number. If that number is between 5000 and 5999, I want YES to appear in cell B1. If the number is less than or more than that range, I want NO to appear in B1. In Lotus, I would have used this formula in B1:

@IF(A1>4999#AND#A1<6000,"YES","NO")

with #AND# being the operative to give me the range. I can't find the equivalent operative in Excel. Excel's AND function doesn't provide for a range and it only returns true or false. Can anyone help me, I'm sure it's possible and easy, just can't seem to locate it.

### Excel Facts

To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
b1 =if(and(a1>=5000,a1<=5999),"yes","no")

On 2002-10-03 08:33, Barry Katcher wrote:
In cell A1, I have a 4 digit number. If that number is between 5000 and 5999, I want YES to appear in cell B1. If the number is less than or more than that range, I want NO to appear in B1. In Lotus, I would have used this formula in B1:

@IF(A1>4999#AND#A1<6000,"YES","NO")

with #AND# being the operative to give me the range. I can't find the equivalent operative in Excel. Excel's AND function doesn't provide for a range and it only returns true or false. Can anyone help me, I'm sure it's possible and easy, just can't seem to locate it.

=(A1>=5000)*(A1<=5999)

Custom format the formula cell as:

[=0]"NO";[=1]"YES"

Thanks, LAS, worked great. Curious, though. I entered 5500 in A1 and changed the formula in B1 to:

=IF(AND(A1=5000,A1=5500),"YES","NO")

and it return NO. Any idea why?

it is not possible for a1 to be both 5000 and 5500 so it will always say NO.

It returned NO because natutrally enough it couldn't satisfy both criteria i.e. it couldn't equal both 5000 and 5500

Aladin - doesn't work. 5500 returns a zero, not a one. What is the * symbol. Is it a multiplier or the symbol for "and"?

O.K, thanks, Bisley & Bolo. If I understand correctly, it satisfied the less than/more than criteria but not both the equal to criteria.

On 2002-10-03 09:07, Barry Katcher wrote:
O.K, thanks, Bisley & Bolo. If I understand correctly, it satisfied the less than/more than criteria but not both the equal to criteria.

If you did want either case, simply substitute
OR for ANDin the "traditional" formula
or
+ for * in Aladin's boolean formula.

Replies
3
Views
161
Replies
8
Views
184
Replies
6
Views
155
Replies
6
Views
511
Replies
3
Views
301

1,218,620
Messages
6,143,518
Members
450,492
Latest member
Rusbus1972

### 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