IF(AND Question

wizardmagu

Board Regular
Joined
Dec 27, 2012
Messages
58
Office Version
  1. 365
Platform
  1. Windows
I am trying to build an IF(AND formula that will evaluate the cell and if it falls in between a given range then assign a value. For some reason I have it working on the first 6 but the last 5 are not working. Any ideas?

=IF(AND(B6>=$S$3,B6<=$R$3),$R$2,IF(AND(B6>=$Q$3,B6<=$P$3),$P$2,IF(AND(B6>=$O$3,B6<=$N$3,$N$2),IF(AND(B6>=$M$3,B6<=$L$3,$L$2),$L$2,""))))
 

Attachments

  • IF AND.jpg
    IF AND.jpg
    101.8 KB · Views: 4

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
You have a closing bracket in the wrong place, try
Excel Formula:
=IF(AND(B6>=$S$3,B6<=$R$3),$R$2,IF(AND(B6>=$Q$3,B6<=$P$3),$P$2,IF(AND(B6>=$O$3,B6<=$N$3),$N$2,IF(AND(B6>=$M$3,B6<=$L$3,$L$2),$L$2,""))))
 
Upvote 0
Update... I used an XLOOKUP to get it to work, but not sure if that is the "right" way to do it.

=XLOOKUP(B6,$L$3:$S$3,$L$2:$S$2,,1)

I would really like to use the IF(AND because it can be a powerful function but wanted to see everyones thoughts?
 

Attachments

  • XLOOKUP.jpg
    XLOOKUP.jpg
    114.9 KB · Views: 4
Upvote 0
You have a closing bracket in the wrong place, try
Excel Formula:
=IF(AND(B6>=$S$3,B6<=$R$3),$R$2,IF(AND(B6>=$Q$3,B6<=$P$3),$P$2,IF(AND(B6>=$O$3,B6<=$N$3),$N$2,IF(AND(B6>=$M$3,B6<=$L$3,$L$2),$L$2,""))))
oh my... Thanks for the catch. Also, The last portion of my formula that shows the final $L$2. I am not really sure how it works and wondering if you can explain?
 
Upvote 0
Missed that & it's also wrong, it should be
Excel Formula:
=IF(AND(B6>=$S$3,B6<=$R$3),$R$2,IF(AND(B6>=$Q$3,B6<=$P$3),$P$2,IF(AND(B6>=$O$3,B6<=$N$3),$N$2,IF(AND(B6>=$M$3,B6<=$L$3),$L$2,""))))
 
Upvote 0
Solution

Forum statistics

Threads
1,214,981
Messages
6,122,565
Members
449,089
Latest member
Motoracer88

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