Need help with IF statement

Barry Katcher

Well-known Member
Joined
Feb 25, 2002
Messages
4,053
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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,210
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"
 

Barry Katcher

Well-known Member
Joined
Feb 25, 2002
Messages
4,053
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?
 

bolo

Active Member
Joined
Mar 23, 2002
Messages
423

ADVERTISEMENT

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

Bisleycat2002

New Member
Joined
Sep 17, 2002
Messages
41
It returned NO because natutrally enough it couldn't satisfy both criteria i.e. it couldn't equal both 5000 and 5500
 

Barry Katcher

Well-known Member
Joined
Feb 25, 2002
Messages
4,053

ADVERTISEMENT

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

Barry Katcher

Well-known Member
Joined
Feb 25, 2002
Messages
4,053
O.K, thanks, Bisley & Bolo. If I understand correctly, it satisfied the less than/more than criteria but not both the equal to criteria.
 

IML

MrExcel MVP
Joined
Feb 15, 2002
Messages
1,743
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.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,092
Messages
5,835,344
Members
430,351
Latest member
ddalton

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Top