Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
KS KS is offline
external usenet poster
 
Posts: 33
Default Nest If - What am I doing wrong...

Hey all,
Hope your day is going better then mine. :)

Getting right to the point...

Here is the formula that goes in column G
=IF(E2<3,"<3",IF(OR(E2=3,E2<=5),"3-5",IF(OR(E2=6,E2<=10),"6-10",IF(OR(E2=11,E2<=15),"11-15",IF(OR(E2=16,E2<=20),"16-20","20")))))

data out of column E
11
15
3
20
-2

actual output of column G from formula
3-5
3-5
3-5
3-5
<3

output that SHOULD be coming into column G
11-15
11-15
3-5
16-20
<3

What is wrong with the formula? Why is it only looking at the first 2 Ifs?
Hope this makes sense, if you have any questions let me know. Any help would
be great. Thanks in advance!
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default Nest If - What am I doing wrong...

It should be AND

=IF(E2<3,"<3",IF(AND(E2=3,E2<=5),"3-5",
IF(AND(E2=6,E2<=10),"6-10",
IF(AND(E2=11,E2<=15),"11-15",
IF(AND(E2=16,E2<=20),"16-20","20")))))

If this post helps click Yes
---------------
Jacob Skaria


"KS" wrote:

Hey all,
Hope your day is going better then mine. :)

Getting right to the point...

Here is the formula that goes in column G
=IF(E2<3,"<3",IF(OR(E2=3,E2<=5),"3-5",IF(OR(E2=6,E2<=10),"6-10",IF(OR(E2=11,E2<=15),"11-15",IF(OR(E2=16,E2<=20),"16-20","20")))))

data out of column E
11
15
3
20
-2

actual output of column G from formula
3-5
3-5
3-5
3-5
<3

output that SHOULD be coming into column G
11-15
11-15
3-5
16-20
<3

What is wrong with the formula? Why is it only looking at the first 2 Ifs?
Hope this makes sense, if you have any questions let me know. Any help would
be great. Thanks in advance!

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,059
Default Nest If - What am I doing wrong...

"KS" wrote:
=IF(E2<3,"<3", IF(OR(E2=3,E2<=5), "3-5", IF(OR(E2=6,E2<=10),
"6-10", IF(OR(E2=11,E2<=15), "11-15", IF(OR(E2=16,E2<=20),
"16-20", "20")))))
[....]
What is wrong with the formula?


The short answer is: you should use AND() instead of OR().

However, the formula can be greatly simplified. At a minimum:

=IF(E2<3,"<3", IF(E2<=5, "3-5", IF(E2<=10, "6-10",
IF(E2<=15, "11-15", IF(E2<=20, "16-20", "20")))))

Even simpler and more-flexible/efficient formulas might also be possible.
But first, it would be helpful to know: (a) is E2 always an integer; and
(b) can E2 be negative?


----- original message -----

"KS" wrote in message
...
Hey all,
Hope your day is going better then mine. :)

Getting right to the point...

Here is the formula that goes in column G
=IF(E2<3,"<3",IF(OR(E2=3,E2<=5),"3-5",IF(OR(E2=6,E2<=10),"6-10",IF(OR(E2=11,E2<=15),"11-15",IF(OR(E2=16,E2<=20),"16-20","20")))))

data out of column E
11
15
3
20
-2

actual output of column G from formula
3-5
3-5
3-5
3-5
<3

output that SHOULD be coming into column G
11-15
11-15
3-5
16-20
<3

What is wrong with the formula? Why is it only looking at the first 2 Ifs?
Hope this makes sense, if you have any questions let me know. Any help
would
be great. Thanks in advance!


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,104
Default Nest If - What am I doing wrong...

1) Your ORs should be ANDs
IF(OR(x 3, x<5, "x is between 3 and 5", "some other value" NO
IF(OR(x 3, x<5, "x is either greater than 3 or less than 5", "some other
value" YES
Could be 2 (less than 5) , 4 (less than 5), 22 (greater than 3) etc (not
very informative)

IF(AND(x 3, x<5,"x is between 3 and 5","some other value" YES
Be sure to study this for future problems


2) but you go not need the AND
=IF(x <3, "X is less than 3", if(X = 5, "x is 3 to 5....
The values lower than 3 are 'trapped' by the first test and do not need to
be test again

So:

=IF(E2<3,"<3",IF(E2<=5,"3-5",IF(E2<=10,"6-10",IF(E2<=15,"11-15",IF(E2<=20,"16-20","20")))))

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email


"KS" wrote in message
...
Hey all,
Hope your day is going better then mine. :)

Getting right to the point...

Here is the formula that goes in column G
=IF(E2<3,"<3",IF(OR(E2=3,E2<=5),"3-5",IF(OR(E2=6,E2<=10),"6-10",IF(OR(E2=11,E2<=15),"11-15",IF(OR(E2=16,E2<=20),"16-20","20")))))

data out of column E
11
15
3
20
-2

actual output of column G from formula
3-5
3-5
3-5
3-5
<3

output that SHOULD be coming into column G
11-15
11-15
3-5
16-20
<3

What is wrong with the formula? Why is it only looking at the first 2 Ifs?
Hope this makes sense, if you have any questions let me know. Any help
would
be great. Thanks in advance!





  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default Nest If - What am I doing wrong...

You can acheive the same using a LOOKUP() function...Easy to edit

=LOOKUP(E2,{0,3,6,11,16,21},{"<3","3-5","6-10","11-15","16-20","20"})


If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

It should be AND

=IF(E2<3,"<3",IF(AND(E2=3,E2<=5),"3-5",
IF(AND(E2=6,E2<=10),"6-10",
IF(AND(E2=11,E2<=15),"11-15",
IF(AND(E2=16,E2<=20),"16-20","20")))))

If this post helps click Yes
---------------
Jacob Skaria


"KS" wrote:

Hey all,
Hope your day is going better then mine. :)

Getting right to the point...

Here is the formula that goes in column G
=IF(E2<3,"<3",IF(OR(E2=3,E2<=5),"3-5",IF(OR(E2=6,E2<=10),"6-10",IF(OR(E2=11,E2<=15),"11-15",IF(OR(E2=16,E2<=20),"16-20","20")))))

data out of column E
11
15
3
20
-2

actual output of column G from formula
3-5
3-5
3-5
3-5
<3

output that SHOULD be coming into column G
11-15
11-15
3-5
16-20
<3

What is wrong with the formula? Why is it only looking at the first 2 Ifs?
Hope this makes sense, if you have any questions let me know. Any help would
be great. Thanks in advance!

  #7   Report Post  
Posted to microsoft.public.excel.misc
KS KS is offline
external usenet poster
 
Posts: 33
Default Nest If - What am I doing wrong...

This is perfect!!! I should have known that...THANK YOU!!!!

"Jacob Skaria" wrote:

It should be AND

=IF(E2<3,"<3",IF(AND(E2=3,E2<=5),"3-5",
IF(AND(E2=6,E2<=10),"6-10",
IF(AND(E2=11,E2<=15),"11-15",
IF(AND(E2=16,E2<=20),"16-20","20")))))

If this post helps click Yes
---------------
Jacob Skaria


"KS" wrote:

Hey all,
Hope your day is going better then mine. :)

Getting right to the point...

Here is the formula that goes in column G
=IF(E2<3,"<3",IF(OR(E2=3,E2<=5),"3-5",IF(OR(E2=6,E2<=10),"6-10",IF(OR(E2=11,E2<=15),"11-15",IF(OR(E2=16,E2<=20),"16-20","20")))))

data out of column E
11
15
3
20
-2

actual output of column G from formula
3-5
3-5
3-5
3-5
<3

output that SHOULD be coming into column G
11-15
11-15
3-5
16-20
<3

What is wrong with the formula? Why is it only looking at the first 2 Ifs?
Hope this makes sense, if you have any questions let me know. Any help would
be great. Thanks in advance!

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,696
Default Nest If - What am I doing wrong...

would be a lot easier to simply enter:
A B
0 <3
3 3-5
6 6-10
11 11-15
16 16-20
21 20

in a table, then you only need to do =VLOOKUP(E2,A:B,2)

"KS" wrote:

Hey all,
Hope your day is going better then mine. :)

Getting right to the point...

Here is the formula that goes in column G
=IF(E2<3,"<3",IF(OR(E2=3,E2<=5),"3-5",IF(OR(E2=6,E2<=10),"6-10",IF(OR(E2=11,E2<=15),"11-15",IF(OR(E2=16,E2<=20),"16-20","20")))))

data out of column E
11
15
3
20
-2

actual output of column G from formula
3-5
3-5
3-5
3-5
<3

output that SHOULD be coming into column G
11-15
11-15
3-5
16-20
<3

What is wrong with the formula? Why is it only looking at the first 2 Ifs?
Hope this makes sense, if you have any questions let me know. Any help would
be great. Thanks in advance!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nest IF....maybe? IF/AND?? Leigh Excel Discussion (Misc queries) 6 December 13th 07 11:03 PM
NEST A IF WITHIN A IF Karine Excel Worksheet Functions 4 November 27th 07 10:11 PM
Insert Calculated Field (wrong Qty*Price = wrong Amount) Edmund Excel Discussion (Misc queries) 8 October 4th 07 12:13 PM
Can I nest Max in HLOOKUP? Cecilia Excel Worksheet Functions 1 September 13th 06 10:37 PM
7+ Nest If's Channing Excel Worksheet Functions 9 January 22nd 05 08:53 PM


All times are GMT +1. The time now is 07:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"