IF AND formula

sadsfan

Board Regular
Joined
Apr 30, 2003
Messages
217
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi I am using Excel 2013 and I want to use an IF AND statement to check the value of 1 cell and another.
So I am checking:
if B1=1 AND B2=100 is true I want to return the value "2" if B1=1 AND B2<100 I want to return the value "1"
if B1=2 AND B2=100 is true I want to return the value "3" if B1=2 AND B2<100 I want to return the value "2"
How can I do this? I am struggling with trying to write a formula and think I may need to use vba, can anyone help?
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Try:
Code:
=IF(AND(B1=2,B2=100),3,IF(OR(AND(B1=2,B2 < 100),AND(B1=1,B2=100)),2,IF(AND(B1=1,B2 < 100),1,"")))
 
Upvote 0
return the value in another cell
if not then VBA

if B1=1 AND B2=100 is true I want to return the value "2" if B1=1 AND B2 < 100 I want to return the value "1"
if B1=2 AND B2=100 is true I want to return the value "3" if B1=2 AND B2 < 100 I want to return the value "2"


if B1=1 AND B2=100 is true I want to return the value "2"
if B1=2 AND B2 < 100 I want to return the value "2"

So thats an OR and AND

AND(B1=1, B2=100)
AND(B1=2, B2 < 100)
if either of those are true - you want a 2

OR(
AND(B1=1, B2=100), AND(B1=2, B2 < 100))
now in the
IF
=IF(
OR(AND(B1=1, B2=100), AND(B1=2, B2 < 100)) , 2,
now we to add a nested IF for 1 and 3
B1=1 AND B2<100 I want to return the value "1"

=AND( B1 =1 , B2 < 100 )
=IF( OR(AND(B1=1, B2=100), AND(B1=2, B2 < 100)) , 2, IF ( AND( B1 =1 , B2 < 100 ) , 1,

then
B1=2 AND B2=100 is true I want to return the value "3"
=AND( B1 =2 , B2 =100 )

=IF( OR(AND(B1=1, B2=100), AND(B1=2, B2 < 100)) , 2, IF ( AND( B1 =1 , B2 < 100 ) , 1, IF ( AND( B1 =2 , B2 =100 ) , 3 , "criteria not met" )))
 
Upvote 0
Try:
Code:
=IF(AND(B1=2,B2=100),3,IF(OR(AND(B1=2,B2 < 100),AND(B1=1,B2=100)),2,IF(AND(B1=1,B2 < 100),1,"")))
Thanks Joe4, that worked perfectly and I can see where I was going wrong.
 
Upvote 0
return the value in another cell
if not then VBA

if B1=1 AND B2=100 is true I want to return the value "2" if B1=1 AND B2 < 100 I want to return the value "1"
if B1=2 AND B2=100 is true I want to return the value "3" if B1=2 AND B2 < 100 I want to return the value "2"


if B1=1 AND B2=100 is true I want to return the value "2"
if B1=2 AND B2 < 100 I want to return the value "2"

So thats an OR and AND

AND(B1=1, B2=100)
AND(B1=2, B2 < 100)
if either of those are true - you want a 2

OR(
AND(B1=1, B2=100), AND(B1=2, B2 < 100))
now in the
IF
=IF(
OR(AND(B1=1, B2=100), AND(B1=2, B2 < 100)) , 2,
now we to add a nested IF for 1 and 3
B1=1 AND B2<100 I want to return the value "1"

=AND( B1 =1 , B2 < 100 )
=IF( OR(AND(B1=1, B2=100), AND(B1=2, B2 < 100)) , 2, IF ( AND( B1 =1 , B2 < 100 ) , 1,

then
B1=2 AND B2=100 is true I want to return the value "3"
=AND( B1 =2 , B2 =100 )

=IF( OR(AND(B1=1, B2=100), AND(B1=2, B2 < 100)) , 2, IF ( AND( B1 =1 , B2 < 100 ) , 1, IF ( AND( B1 =2 , B2 =100 ) , 3 , "criteria not met" )))
Thanks Etaf, if I have any trouble with Joe4's formula, I'll use this code.
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,262
Members
452,627
Latest member
KitkatToby

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
Back
Top