ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Nested IF not working..... (https://www.excelbanter.com/excel-worksheet-functions/204549-nested-if-not-working.html)

Patrick

Nested IF not working.....
 
Here is the formula that I'm using:

=IF(K2={71876,147825,186110,73859,1183639,163773,1 40408,226473},"GSA",IF(K2={235842,245561,235823,23 5843,245337,239135,200830},"CNB",IF(K2={683983,245 144,29839,4813,67555,175821,82901,175645,139429,17 5397,131445,979352,113854,972262,174756,218880,335 8},"CB","ADJ")))

When K2 has any of the values listed in the first part of the IF it returns
GSA, like it's supposed to. BUT....if any of the other values listed in the
subsequent parts are in K2 it always list ADJ, like it's not in any of the
other list. I can't get it to return CNB or CB. Any ideas why?

Tom Hutchins

Nested IF not working.....
 
If I enter 235842 in K2, your formula returns CNB, and if I enter 683983, it
returns CB. I don't know for sure, but I might guess that Excel doesn't like
more than one array of values in brackets in a single formula. It seems to
accept the first value in each subsequent array and ignore the rest. Instead
of the nested IFs, you could enter the numbers and the values they should
return in a couple of empty columns, then use a VLOOKUP formula. If, for
example, you entered your data like this in columns M & N:

71876 GSA
147825 GSA
186110 GSA
73859 GSA
1183639 GSA
16773 GSA
140408 GSA
226473 GSA
235842 CNB
245561 CNB
235823 CNB
etc.

Your Vlookup formula would be

=IF(ISERROR(VLOOKUP(K2,M:N,2,FALSE)),"ADJ",VLOOKUP (K2,M:N,2,FALSE))

If it finds the K2 number in column M, the code next to it in column N is
returned. If the K2 value is not found in column M, ADJ is returned.

Hope this helps,

Hutch

"Patrick" wrote:

Here is the formula that I'm using:

=IF(K2={71876,147825,186110,73859,1183639,163773,1 40408,226473},"GSA",IF(K2={235842,245561,235823,23 5843,245337,239135,200830},"CNB",IF(K2={683983,245 144,29839,4813,67555,175821,82901,175645,139429,17 5397,131445,979352,113854,972262,174756,218880,335 8},"CB","ADJ")))

When K2 has any of the values listed in the first part of the IF it returns
GSA, like it's supposed to. BUT....if any of the other values listed in the
subsequent parts are in K2 it always list ADJ, like it's not in any of the
other list. I can't get it to return CNB or CB. Any ideas why?


JMB

Nested IF not working.....
 
When K2 has any value in the first part of the formula other than 71876, it
returns "ADJ" for me.

you'll need to use OR for your conditional tests.
OR(K2={71876,147825,186110,73859,1183639,163773,14 0408,226473})

"Patrick" wrote:

Here is the formula that I'm using:

=IF(K2={71876,147825,186110,73859,1183639,163773,1 40408,226473},"GSA",IF(K2={235842,245561,235823,23 5843,245337,239135,200830},"CNB",IF(K2={683983,245 144,29839,4813,67555,175821,82901,175645,139429,17 5397,131445,979352,113854,972262,174756,218880,335 8},"CB","ADJ")))

When K2 has any of the values listed in the first part of the IF it returns
GSA, like it's supposed to. BUT....if any of the other values listed in the
subsequent parts are in K2 it always list ADJ, like it's not in any of the
other list. I can't get it to return CNB or CB. Any ideas why?


Sandy Mann

Nested IF not working.....
 
You need to enclose your arrays in an OR() function:

=IF(OR(K2={71876,147825,186110,73859,1183639,16377 3,140408,226473}),"GSA",IF(OR(K2={235842,245561,23 5823,235843,245337,239135,200830}),"CNB",IF(OR(K2= {683983,245144,29839,4813,67555,175821,82901,17564 5,139429,175397,131445,979352,113854,972262,174756 ,218880,3358}),"CB","ADJ")))

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


Replace @mailinator.com with @tiscali.co.uk


"Patrick" wrote in message
...
Here is the formula that I'm using:

=IF(K2={71876,147825,186110,73859,1183639,163773,1 40408,226473},"GSA",IF(K2={235842,245561,235823,23 5843,245337,239135,200830},"CNB",IF(K2={683983,245 144,29839,4813,67555,175821,82901,175645,139429,17 5397,131445,979352,113854,972262,174756,218880,335 8},"CB","ADJ")))

When K2 has any of the values listed in the first part of the IF it
returns
GSA, like it's supposed to. BUT....if any of the other values listed in
the
subsequent parts are in K2 it always list ADJ, like it's not in any of the
other list. I can't get it to return CNB or CB. Any ideas why?




Patrick

Nested IF not working.....
 
That worked perfect. Thanks so much. I knew I was close.

"JMB" wrote:

When K2 has any value in the first part of the formula other than 71876, it
returns "ADJ" for me.

you'll need to use OR for your conditional tests.
OR(K2={71876,147825,186110,73859,1183639,163773,14 0408,226473})

"Patrick" wrote:

Here is the formula that I'm using:

=IF(K2={71876,147825,186110,73859,1183639,163773,1 40408,226473},"GSA",IF(K2={235842,245561,235823,23 5843,245337,239135,200830},"CNB",IF(K2={683983,245 144,29839,4813,67555,175821,82901,175645,139429,17 5397,131445,979352,113854,972262,174756,218880,335 8},"CB","ADJ")))

When K2 has any of the values listed in the first part of the IF it returns
GSA, like it's supposed to. BUT....if any of the other values listed in the
subsequent parts are in K2 it always list ADJ, like it's not in any of the
other list. I can't get it to return CNB or CB. Any ideas why?


JMB

Nested IF not working.....
 
you're welcome.

"Patrick" wrote:

That worked perfect. Thanks so much. I knew I was close.

"JMB" wrote:

When K2 has any value in the first part of the formula other than 71876, it
returns "ADJ" for me.

you'll need to use OR for your conditional tests.
OR(K2={71876,147825,186110,73859,1183639,163773,14 0408,226473})

"Patrick" wrote:

Here is the formula that I'm using:

=IF(K2={71876,147825,186110,73859,1183639,163773,1 40408,226473},"GSA",IF(K2={235842,245561,235823,23 5843,245337,239135,200830},"CNB",IF(K2={683983,245 144,29839,4813,67555,175821,82901,175645,139429,17 5397,131445,979352,113854,972262,174756,218880,335 8},"CB","ADJ")))

When K2 has any of the values listed in the first part of the IF it returns
GSA, like it's supposed to. BUT....if any of the other values listed in the
subsequent parts are in K2 it always list ADJ, like it's not in any of the
other list. I can't get it to return CNB or CB. Any ideas why?



All times are GMT +1. The time now is 06:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com