Nested IF AND statement

wezzy28

New Member
Joined
Mar 12, 2018
Messages
9
Hello!

It's my first time here and I'm looking for help.

I have this formula:
=IF(and(J8<$X$8, J8>=$W$8, $Y$8, IF(AND(J8<$X$9, J8>=$W$9, $Y$9, IF(AND(J8<$X$10, J8>=$W$10, $Y$10, IF(AND(J8<$X$11, J8>=$W$11, $Y$11, IF(AND(J8<$X$12, J8>=$W$12, $Y$12, IF(AND(J8<$X$13, J8>=$W$13, $Y$13, IF(AND(J8<$X$14, J8>=$W$14,$Y$14, IF(AND(J8<$X$15, J8>=$W$15, $Y$15, IF(AND(J8<$X$16, J8>=$W$16, $Y$16, IF(AND(J8<$X$17, J8>=$W$17, $Y$17, if(and(j8>=$w$18, $Y$18,"none")))))))))))

What I'm trying to achieve is:

If cell J8's value is between 0 (X8) and 0.01(W8) then display value of cell Y8
elseif J8 is between X9 and W9 then display Y9

and it goes on until row 18

The above formula is rendering errors and wouldn't let me move forward until I've corrected the error. I tried different combinations and still nothing.

I would appreciate any assistance.

It's kind of urgent for a project which is due tomorrow.

Thank you.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
you need to close the AND( bracket
=IF(and(J8<$X$8, J8>=$W$8) ,
which is why its not working
you are not going to use a IF in the middle of an AND()

I dont understand
If cell J8's value is between 0 (X8) and 0.01(W8)
If cell J8's value is between 0 (X8) and 0.01(W8) then display value of cell Y8

X8 has to be at 0
W8 has to be at 0.01
Then J8 needs to be between those values

AND( X8 = 0, W8=0.01 , J8 >= 0, J8<=0.01)
is that the rule you are after ???


 
Upvote 0
Welcome to the Board.

I really dislike deeply nested formulas like that. Usually there's a much shorter way to code it using lookup functions, or possibly array formulas. Either of which would be far simpler to understand and maintain. For example, if you have a table of non-overlapping values, you can replace that whole formula with a simple VLOOKUP:

JKWXY
817d15a
9610b
101115c
111620d
122125e
132630f
143135g
153640h
164145i
174650j
185155k

<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet5

Worksheet Formulas
CellFormula
K8=VLOOKUP(J8,$W$8:$Y$18,3)

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>



If your table is different, let us know and there may still be an easier way to do it.
 
Upvote 0
Hi Wayne!!

Thank you for the quick reply!

I closed the brackets after the 'and' - like you suggested - and it worked!!

J8 contains values (area) calculated from other cells. I hope I'm making sense?

deoemc.png


I need to populate the Column P...

Thank you so much!!
 
Upvote 0
Hi Eric,

Thank you for taking time to find a solution to my problem. I resolved it from the first reply. I've posted my excel sheet above and if you do find a much easier solution, I'm all ears! And grateful.

:)
 
Upvote 0
Your tables are set up exactly the way I set up my example. You should be able to put the exact formula I posted in post # 3 in your P8 cell and drag down.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,560
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