#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default IF FUNCTION

hi

Please could someone advise what is wrong with this formula:

=IF(B26<=0,"0%",IF(B26=1<=4,"5%",IF(B26<=4,"5%",I F(B26=5<=14,"25%",IF(B26<=14,"25%",IF(B26=15<=24 ,"50%",IF(B26<=24,"50%",IF(B26=25,"75%"))))))) )


The problem is if B26<0 it works...but if B26=0 it evaluates to 5% not
to 0% as it should according to the formula.


Thanks
Vasen
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default IF FUNCTION

Breaking this down to a UDF shows your IF is wat=y too
complex:

Function Percents(dValue As Double) As String

Dim sReturn As String

Select Case dValue
Case Is <= 0: sReturn = "0%"
Case Is <= 4: sReturn = "5%"
Case Is <= 14: sReturn = "25%"
Case Is <= 24: sReturn = "50%"
Case Else: sReturn = "75%"
End Select

Percents = sReturn

End Function



IF(B26<=0,"0%,IF(B26<=4,"5%,IF(B26<=14,"25%",IF
(B26<=24,"50%","75%"))))


Patrick Molloy
Microsoft Excel MVP

-----Original Message-----
hi

Please could someone advise what is wrong with this

formula:

=IF(B26<=0,"0%",IF(B26=1<=4,"5%",IF(B26<=4,"5%", IF

(B26=5<=14,"25%",IF(B26<=14,"25%",IF(B26=15<=24, "50%",IF
(B26<=24,"50%",IF(B26=25,"75%"))))))))


The problem is if B26<0 it works...but if B26=0 it

evaluates to 5% not
to 0% as it should according to the formula.


Thanks
Vasen
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default IF FUNCTION

Hi Vasen,

Your formula has a lot of oddities and can be corrected and simplified with

=IF(B26<=0,0%,IF(AND(B260,B26<=4),5%,IF(AND(B264 ,B26<=14),25%,IF(AND(B261
4,B26<=24),50%,75%))))

Firstly, you don't test and AND condition like B26=1<=4 but as
AND(B260,B26<=4)
The, percentage is a value so you don't need it within quotes, just format
the cell as percentage to see 5% rather than 0.05
You don't test for values between 0 and 1 (and others), so I assume this
means that it can on ly be whole numbers, so tests like
IF(B26<=0,0%,IF(AND(B26=1,B26<=4 are better covered by
IF(B26<=0,0%,IF(AND(B260,B26<=4 to catch all instances and to make more
readable

Because it seems to work only on whole numbers you could also use CHOOSE

=IF(B264,75%,CHOOSE(B26+1,0%,5%,25%,50%))

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"vee" wrote in message
om...
hi

Please could someone advise what is wrong with this formula:


=IF(B26<=0,"0%",IF(B26=1<=4,"5%",IF(B26<=4,"5%",I F(B26=5<=14,"25%",IF(B26<
=14,"25%",IF(B26=15<=24,"50%",IF(B26<=24,"50%",IF (B26=25,"75%"))))))))


The problem is if B26<0 it works...but if B26=0 it evaluates to 5% not
to 0% as it should according to the formula.


Thanks
Vasen



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default IF FUNCTION

I believe you can simplify this even more. You do not need the AND
statements at all since the previous IF would have dealt with it if the
lower value in the AND was releveant, hence:

=IF(B26<=0,0%,IF(B26<=4,5%,IF(B26<=14,25%,IF(B26<= 24),50%,75%))))

should work (assuming B26 is always numeric).


"Bob Phillips" wrote in message
...
Hi Vasen,

Your formula has a lot of oddities and can be corrected and simplified

with


=IF(B26<=0,0%,IF(AND(B260,B26<=4),5%,IF(AND(B264 ,B26<=14),25%,IF(AND(B261
4,B26<=24),50%,75%))))

Firstly, you don't test and AND condition like B26=1<=4 but as
AND(B260,B26<=4)
The, percentage is a value so you don't need it within quotes, just format
the cell as percentage to see 5% rather than 0.05
You don't test for values between 0 and 1 (and others), so I assume this
means that it can on ly be whole numbers, so tests like
IF(B26<=0,0%,IF(AND(B26=1,B26<=4 are better covered by
IF(B26<=0,0%,IF(AND(B260,B26<=4 to catch all instances and to make more
readable

Because it seems to work only on whole numbers you could also use CHOOSE

=IF(B264,75%,CHOOSE(B26+1,0%,5%,25%,50%))

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"vee" wrote in message
om...
hi

Please could someone advise what is wrong with this formula:



=IF(B26<=0,"0%",IF(B26=1<=4,"5%",IF(B26<=4,"5%",I F(B26=5<=14,"25%",IF(B26<
=14,"25%",IF(B26=15<=24,"50%",IF(B26<=24,"50%",IF (B26=25,"75%"))))))))


The problem is if B26<0 it works...but if B26=0 it evaluates to 5% not
to 0% as it should according to the formula.


Thanks
Vasen







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default IF FUNCTION

I agree, but I didn't go down that path because I wanted to espouse the
CHOOSE option , which I think is better.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Lorne" wrote in message
...
I believe you can simplify this even more. You do not need the AND
statements at all since the previous IF would have dealt with it if the
lower value in the AND was releveant, hence:

=IF(B26<=0,0%,IF(B26<=4,5%,IF(B26<=14,25%,IF(B26<= 24),50%,75%))))

should work (assuming B26 is always numeric).


"Bob Phillips" wrote in message
...
Hi Vasen,

Your formula has a lot of oddities and can be corrected and simplified

with



=IF(B26<=0,0%,IF(AND(B260,B26<=4),5%,IF(AND(B264 ,B26<=14),25%,IF(AND(B261
4,B26<=24),50%,75%))))

Firstly, you don't test and AND condition like B26=1<=4 but as
AND(B260,B26<=4)
The, percentage is a value so you don't need it within quotes, just

format
the cell as percentage to see 5% rather than 0.05
You don't test for values between 0 and 1 (and others), so I assume this
means that it can on ly be whole numbers, so tests like
IF(B26<=0,0%,IF(AND(B26=1,B26<=4 are better covered by
IF(B26<=0,0%,IF(AND(B260,B26<=4 to catch all instances and to make more
readable

Because it seems to work only on whole numbers you could also use CHOOSE

=IF(B264,75%,CHOOSE(B26+1,0%,5%,25%,50%))

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"vee" wrote in message
om...
hi

Please could someone advise what is wrong with this formula:




=IF(B26<=0,"0%",IF(B26=1<=4,"5%",IF(B26<=4,"5%",I F(B26=5<=14,"25%",IF(B26<
=14,"25%",IF(B26=15<=24,"50%",IF(B26<=24,"50%",IF (B26=25,"75%"))))))))


The problem is if B26<0 it works...but if B26=0 it evaluates to 5% not
to 0% as it should according to the formula.


Thanks
Vasen







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default IF FUNCTION

Hi Bob!

And I was shocked and stunned to find that it worked <vbg

--
Regards
Norman Harker MVP (Excel)
Sydney, Australia

Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
"Bob Phillips" wrote in message
...
I agree, but I didn't go down that path because I wanted to espouse

the
CHOOSE option , which I think is better.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Lorne" wrote in message
...
I believe you can simplify this even more. You do not need the

AND
statements at all since the previous IF would have dealt with it

if the
lower value in the AND was releveant, hence:

=IF(B26<=0,0%,IF(B26<=4,5%,IF(B26<=14,25%,IF(B26<= 24),50%,75%))))

should work (assuming B26 is always numeric).


"Bob Phillips" wrote in

message
...
Hi Vasen,

Your formula has a lot of oddities and can be corrected and

simplified
with




=IF(B26<=0,0%,IF(AND(B260,B26<=4),5%,IF(AND(B264 ,B26<=14),25%,IF(AND
(B261
4,B26<=24),50%,75%))))

Firstly, you don't test and AND condition like B26=1<=4 but as
AND(B260,B26<=4)
The, percentage is a value so you don't need it within quotes,

just
format
the cell as percentage to see 5% rather than 0.05
You don't test for values between 0 and 1 (and others), so I

assume this
means that it can on ly be whole numbers, so tests like
IF(B26<=0,0%,IF(AND(B26=1,B26<=4 are better covered by
IF(B26<=0,0%,IF(AND(B260,B26<=4 to catch all instances and to

make more
readable

Because it seems to work only on whole numbers you could also

use CHOOSE

=IF(B264,75%,CHOOSE(B26+1,0%,5%,25%,50%))

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"vee" wrote in message
om...
hi

Please could someone advise what is wrong with this formula:





=IF(B26<=0,"0%",IF(B26=1<=4,"5%",IF(B26<=4,"5%",I F(B26=5<=14,"25%",I
F(B26<

=14,"25%",IF(B26=15<=24,"50%",IF(B26<=24,"50%",IF (B26=25,"75%"))))))
))


The problem is if B26<0 it works...but if B26=0 it evaluates

to 5% not
to 0% as it should according to the formula.


Thanks
Vasen








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
Excel Data Validation/Lookup function does function correcty Kirkey Excel Worksheet Functions 2 May 25th 09 09:22 PM
LINKEDRANGE function - a complement to the PULL function (for getting values from a closed workbook) [email protected] Excel Worksheet Functions 0 September 5th 06 03:44 PM
Offset function with nested match function not finding host ss. MKunert Excel Worksheet Functions 1 March 21st 06 10:46 PM
Adding a custom function to the default excel function list DonutDel Excel Programming 3 November 21st 03 03:41 PM
User-Defined Function pre-empting Built-in Function? How to undo???? MarWun Excel Programming 1 August 6th 03 09:31 PM


All times are GMT +1. The time now is 05:35 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"