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.
 

Some videos you may like

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Aladin Akyurek

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

Watch MrExcel Video

Forum statistics

Threads
1,122,517
Messages
5,596,620
Members
414,081
Latest member
Subaru_Steve

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