Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 59
Default Nested If statement to find greater than but less than numbers

Hi,

I had this formula that works well:

=IF(M20=1.5,"3",IF(AND(M20=1,M20<1.5),"2",IF(AND (M20=0.5,M20<1),"1",IF(AND(M20=0.25,M20<0.5),"0. 5",IF(M20<=0.25,"0.5","error")))))

so I thought I will add another cell for it to check in the AND part so
the formula looked like this:

=IF(AND(M19=1.5,Q19=3),"3",IF(AND(M19=1,M19<1.5 ,Q19=2,Q19<3),"2",IF(AND(M19=0.5,M19<1,Q19=1,Q1 9<2),"1",IF(AND(M19=0.25,M19<0.5,Q19=0.5,Q19<1), "0.5",IF(AND(M19<=0.25,Q19<0.5),"0.5","error") ))))

But now it just returns "error"

Have I dont something illegal here?

Why cant it just after looking at m19 cell, just look at q19 also
before displaying its result?

Cheers for advice,

Aaron.

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default Nested If statement to find greater than but less than numbers

On 9 Nov 2006 16:34:34 -0800, "Aaron" wrote:

Hi,

I had this formula that works well:

=IF(M20=1.5,"3",IF(AND(M20=1,M20<1.5),"2",IF(AN D(M20=0.5,M20<1),"1",IF(AND(M20=0.25,M20<0.5),"0 .5",IF(M20<=0.25,"0.5","error")))))

so I thought I will add another cell for it to check in the AND part so
the formula looked like this:

=IF(AND(M19=1.5,Q19=3),"3",IF(AND(M19=1,M19<1. 5,Q19=2,Q19<3),"2",IF(AND(M19=0.5,M19<1,Q19=1,Q 19<2),"1",IF(AND(M19=0.25,M19<0.5,Q19=0.5,Q19<1) ,"0.5",IF(AND(M19<=0.25,Q19<0.5),"0.5","error")))) )

But now it just returns "error"

Have I dont something illegal here?

Why cant it just after looking at m19 cell, just look at q19 also
before displaying its result?

Cheers for advice,

Aaron.


I presume it is returning the string "error" which you have as the final string
to return.

When you write "now it just returns "error"", what sorts of values did you
test?

Did you try, for example, M19=1 and Q19=2? With those values, your formula on
my worksheet returns 2.

And why do you make it so complicated?

For example, you have:

=IF(M20=1.5,"3",
IF(AND(M20=1,M20<1.5),"2",...

If you get past the first IF, why do you need to test for M20<1.5? If M20 were
not <1.5, then the first IF would test TRUE and the formula would give a "3".
There's no reason to test it again, and it makes your formula much more
confusing to read.

And are you certain you want to return your numbers as string values, rather
than numeric values?

Your first formula could be simplified:

=IF(M20=1.5,"3",
IF(M20=1,"2",
IF(M20=0.5,"1",
IF(M20=0.25,"0.5","error"))))

or, if you really want numeric returns and not strings:

=IF(M20=1.5,3,
IF(M20=1,2,
IF(M20=0.5,1,
IF(M20=0.25,0.5,"error"))))

Your second formula can probably be simplified, but you need to be clear in
your mind as to what you are testing for.



But your formulas are doing exactly what you have told them to do.
--ron
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 59
Default Nested If statement to find greater than but less than numbers

Hi Ron,

With some lateral thinking based on your recommendations, I think I
have now sorted it thanks.

Aaron.








Ron Rosenfeld wrote:
On 9 Nov 2006 16:34:34 -0800, "Aaron" wrote:

Hi,

I had this formula that works well:

=IF(M20=1.5,"3",IF(AND(M20=1,M20<1.5),"2",IF(AN D(M20=0.5,M20<1),"1",IF(AND(M20=0.25,M20<0.5),"0 .5",IF(M20<=0.25,"0.5","error")))))

so I thought I will add another cell for it to check in the AND part so
the formula looked like this:

=IF(AND(M19=1.5,Q19=3),"3",IF(AND(M19=1,M19<1. 5,Q19=2,Q19<3),"2",IF(AND(M19=0.5,M19<1,Q19=1,Q 19<2),"1",IF(AND(M19=0.25,M19<0.5,Q19=0.5,Q19<1) ,"0.5",IF(AND(M19<=0.25,Q19<0.5),"0.5","error")))) )

But now it just returns "error"

Have I dont something illegal here?

Why cant it just after looking at m19 cell, just look at q19 also
before displaying its result?

Cheers for advice,

Aaron.


I presume it is returning the string "error" which you have as the final string
to return.

When you write "now it just returns "error"", what sorts of values did you
test?

Did you try, for example, M19=1 and Q19=2? With those values, your formula on
my worksheet returns 2.

And why do you make it so complicated?

For example, you have:

=IF(M20=1.5,"3",
IF(AND(M20=1,M20<1.5),"2",...

If you get past the first IF, why do you need to test for M20<1.5? If M20 were
not <1.5, then the first IF would test TRUE and the formula would give a "3".
There's no reason to test it again, and it makes your formula much more
confusing to read.

And are you certain you want to return your numbers as string values, rather
than numeric values?

Your first formula could be simplified:

=IF(M20=1.5,"3",
IF(M20=1,"2",
IF(M20=0.5,"1",
IF(M20=0.25,"0.5","error"))))

or, if you really want numeric returns and not strings:

=IF(M20=1.5,3,
IF(M20=1,2,
IF(M20=0.5,1,
IF(M20=0.25,0.5,"error"))))

Your second formula can probably be simplified, but you need to be clear in
your mind as to what you are testing for.



But your formulas are doing exactly what you have told them to do.
--ron


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default Nested If statement to find greater than but less than numbers

On 9 Nov 2006 18:31:41 -0800, "Aaron" wrote:

Hi Ron,

With some lateral thinking based on your recommendations, I think I
have now sorted it thanks.

Aaron.


I'm glad to have pointed you in a productive direction. Thanks for the
feedback.


--ron
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
A Macro to find missing serial numbers in a column Khoshravan Excel Discussion (Misc queries) 9 August 6th 06 10:37 AM
How do I find the 12 highest numbers in a row of 52 numbers Johnny Excel Worksheet Functions 3 July 8th 06 11:58 PM
Find all numbers in database that end in... eschaet Excel Worksheet Functions 3 April 28th 06 04:38 AM
find sum in list of of numbers Jim Thomlinson Excel Discussion (Misc queries) 3 January 4th 06 09:58 PM
7+ nested if statement? Turi Excel Worksheet Functions 3 December 20th 04 07:55 PM


All times are GMT +1. The time now is 11:49 PM.

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"