Using And(OR

sadsfan

Board Regular
Joined
Apr 30, 2003
Messages
217
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi, I'm struggling using the and(or function in Excel 2003. I trying to return a value of 1 if cell cg5 and cell am5 match particular criteria. I want to check:
if cell cg5=1 and am5= 19 or 21 or 23
or if cell cg5=2 and am5= 25 or 27 or 29
or if cell cg5=3 and am5= 31 or 33 or 35

This my formula so far, I keep getting a FALSE value, where am I going wrong?

=and(or(cg5=1),or(am5=19,am5=21,am5=23)*1,1,and(or(cg5=2),or(am5=25,am5=27,am5=29)*1,1,and(or(cg5=3),or(am5=31,am5=33,am5=35)*1,1)))
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hi, I'm struggling using the and(or function in Excel 2003. I trying to return a value of 1 if cell cg5 and cell am5 match particular criteria. I want to check:
if cell cg5=1 and am5= 19 or 21 or 23
or if cell cg5=2 and am5= 25 or 27 or 29
or if cell cg5=3 and am5= 31 or 33 or 35

This my formula so far, I keep getting a FALSE value, where am I going wrong?

=and(or(cg5=1),or(am5=19,am5=21,am5=23)*1,1,and(or(cg5=2),or(am5=25,am5=27,am5=29)*1,1,and(or(cg5=3),or(am5=31,am5=33,am5=35)*1,1)))
Here's one way...

=--OR(AND(CG5=1,OR(AM5={19,21,23})),AND(CG5=2,OR(AM5={25,27,29})),AND(CG5=3,OR(AM5={31,33,35})))
 
Upvote 0
=or(and(cg5=1,or(am5=19,am5=21,am5=23)),and(cg5=2,or(am5=25,am5=27,am5=29)),and(cg5=3,or(am5=31,am5=33,am5=35)))
 
Upvote 0
Here's one way...

=--OR(AND(CG5=1,OR(AM5={19,21,23})),AND(CG5=2,OR(AM5={25,27,29})),AND(CG5=3,OR(AM5={31,33,35})))

What does this "--" do in the formula you have given? Will the formula work without them also?
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,750
Members
452,940
Latest member
rootytrip

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