ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   how do i if statement for 3 variables (https://www.excelbanter.com/excel-worksheet-functions/169483-how-do-i-if-statement-3-variables.html)

wheefus

how do i if statement for 3 variables
 
hi
i have a problem with using the if statement. i am updating a calculator
where a new value for the 2008 year.

here is the old if statement:
=IF(C1<=2006,16.8,22)*N1 giving a result for any date of 2006 or before
of 16.8 and 22 for 2007. N1 HAS A VALUE IN THE CELL
I taught that this was the updated calculator as 2008 has value of 24 to
return

=IF(C1<=2006,16.8,IF(C1=2007,22,IF(C1=2008,24)))* N1
I PUT THIS IN BUT THE RESULT RETURNED FOR 2008 STAYED AT 22

ANY IDEAS ??

p.s. C1 HAS CODE IN THE VISUAL BASIC EDITOR DOES THIS HAVE TO BE CHANGED TO
INCORPOATE THE 2008 VALUE?

David Biddulph[_2_]

how do i if statement for 3 variables
 
What do you get with the formula =C1?
Another thing to check if you are not getting the expected result is Tools/
Options/ Calculation, & make sure is says Automatic, not Manual.
--
David Biddulph

"wheefus" wrote in message
...
hi
i have a problem with using the if statement. i am updating a calculator
where a new value for the 2008 year.

here is the old if statement:
=IF(C1<=2006,16.8,22)*N1 giving a result for any date of 2006 or
before
of 16.8 and 22 for 2007. N1 HAS A VALUE IN THE
CELL
I taught that this was the updated calculator as 2008 has value of 24 to
return

=IF(C1<=2006,16.8,IF(C1=2007,22,IF(C1=2008,24)))* N1
I PUT THIS IN BUT THE RESULT RETURNED FOR 2008 STAYED AT 22

ANY IDEAS ??

p.s. C1 HAS CODE IN THE VISUAL BASIC EDITOR DOES THIS HAVE TO BE CHANGED
TO
INCORPOATE THE 2008 VALUE?




joeu2004

how do i if statement for 3 variables
 
On Dec 12, 2:27 pm, wheefus wrote:
here is the old if statement:
=IF(C1<=2006,16.8,22)*N1

giving a result for any date of 2006 or before of 16.8 and 22 for 2007.
[....] I taught that this was the updated calculator as 2008 has value
of 24 to return
=IF(C1<=2006,16.8,IF(C1=2007,22,IF(C1=2008,24)))* N1


Following the paradigm of the first example, you should be able to
simplifiy the latter example as follows:

=IF(C1<=2006, 16.8, IF(C1<=2007, 22, 24))*N1

But that probably does not solve your problem.

I PUT THIS IN BUT THE RESULT RETURNED FOR 2008 STAYED AT 22
ANY IDEAS ??


Of course, it depends on what is in C1. If you have Excel 2003 or
later, click on ToolsFormula AuditingEvaluate Formula to step
through the formula evaluation. That might help you see the problem.
Off-hand, I do not see any problem with the extended logic of the IF()
expression, even as you wrote it.

(Unless C1 has a value greater than 2007 but less than 2008, which is
expected to be interpreted as the "2008" condition -- that is, your
IF() expression is intended to result in 24.)

p.s. C1 HAS CODE IN THE VISUAL BASIC EDITOR DOES THIS HAVE
TO BE CHANGED TO INCORPOATE THE 2008 VALUE?


That is very real possibility. There is no way for us to know unless
you post the VBA code. Then again, it might be complicated and not
worth our time to dissect. Using the Evaluate Formula tool should
help you see if that is where the problem is.

PS: If you do not have Evaluate Formula (Excel 2000 or earlier, I
believe), you could highlight portions of the formula in the "fx"
function field under the toolbar and use F9 to see how the sub-
expression is evaluated. Personally, I don't like that approach, at
least not as it is implemented in Excel 2003. But apparently it has
been recommended by experts in these NGs.


KLEBESTIFT

how do i if statement for 3 variables
 
The way I do 'evaluate formula' in excel 2000, is to click the = button next
to the formula. It opens a window which shows the current function, what all
the variables for it are and what everything currently evaluates to. Then
click on different functions to go up/down the chain.

"joeu2004" wrote:

On Dec 12, 2:27 pm, wheefus wrote:
here is the old if statement:
=IF(C1<=2006,16.8,22)*N1

giving a result for any date of 2006 or before of 16.8 and 22 for 2007.
[....] I taught that this was the updated calculator as 2008 has value
of 24 to return
=IF(C1<=2006,16.8,IF(C1=2007,22,IF(C1=2008,24)))* N1


Following the paradigm of the first example, you should be able to
simplifiy the latter example as follows:

=IF(C1<=2006, 16.8, IF(C1<=2007, 22, 24))*N1

But that probably does not solve your problem.

I PUT THIS IN BUT THE RESULT RETURNED FOR 2008 STAYED AT 22
ANY IDEAS ??


Of course, it depends on what is in C1. If you have Excel 2003 or
later, click on ToolsFormula AuditingEvaluate Formula to step
through the formula evaluation. That might help you see the problem.
Off-hand, I do not see any problem with the extended logic of the IF()
expression, even as you wrote it.

(Unless C1 has a value greater than 2007 but less than 2008, which is
expected to be interpreted as the "2008" condition -- that is, your
IF() expression is intended to result in 24.)

p.s. C1 HAS CODE IN THE VISUAL BASIC EDITOR DOES THIS HAVE
TO BE CHANGED TO INCORPOATE THE 2008 VALUE?


That is very real possibility. There is no way for us to know unless
you post the VBA code. Then again, it might be complicated and not
worth our time to dissect. Using the Evaluate Formula tool should
help you see if that is where the problem is.

PS: If you do not have Evaluate Formula (Excel 2000 or earlier, I
believe), you could highlight portions of the formula in the "fx"
function field under the toolbar and use F9 to see how the sub-
expression is evaluated. Personally, I don't like that approach, at
least not as it is implemented in Excel 2003. But apparently it has
been recommended by experts in these NGs.



Bernd P

how do i if statement for 3 variables
 
=N1*CHOOSE(2+SIGN(2007-C1),24,22,16.8)

Regards,
Bernd

wheefus

how do i if statement for 3 variables
 

hi the excel program in relation to the question you answered for me earlier
i can email you the program as it cant be posted here
cheers
as answer didnt work

"David Biddulph" wrote:

What do you get with the formula =C1?
Another thing to check if you are not getting the expected result is Tools/
Options/ Calculation, & make sure is says Automatic, not Manual.
--
David Biddulph

"wheefus" wrote in message
...
hi
i have a problem with using the if statement. i am updating a calculator
where a new value for the 2008 year.

here is the old if statement:
=IF(C1<=2006,16.8,22)*N1 giving a result for any date of 2006 or
before
of 16.8 and 22 for 2007. N1 HAS A VALUE IN THE
CELL
I taught that this was the updated calculator as 2008 has value of 24 to
return

=IF(C1<=2006,16.8,IF(C1=2007,22,IF(C1=2008,24)))* N1
I PUT THIS IN BUT THE RESULT RETURNED FOR 2008 STAYED AT 22

ANY IDEAS ??

p.s. C1 HAS CODE IN THE VISUAL BASIC EDITOR DOES THIS HAVE TO BE CHANGED
TO
INCORPOATE THE 2008 VALUE?





wheefus

how do i if statement for 3 variables
 
hi the excel program in relation to the question you answered for me earlier
i can email you the program as it cant be posted here
cheers
as answer didnt work

"Bernd P" wrote:

=N1*CHOOSE(2+SIGN(2007-C1),24,22,16.8)

Regards,
Bernd


wheefus

how do i if statement for 3 variables
 
hi the excel program in relation to the question you answered for me earlier
i can email you the program as it cant be posted here
cheers
as answer didnt work

"KLEBESTIFT" wrote:

The way I do 'evaluate formula' in excel 2000, is to click the = button next
to the formula. It opens a window which shows the current function, what all
the variables for it are and what everything currently evaluates to. Then
click on different functions to go up/down the chain.

"joeu2004" wrote:

On Dec 12, 2:27 pm, wheefus wrote:
here is the old if statement:
=IF(C1<=2006,16.8,22)*N1

giving a result for any date of 2006 or before of 16.8 and 22 for 2007.
[....] I taught that this was the updated calculator as 2008 has value
of 24 to return
=IF(C1<=2006,16.8,IF(C1=2007,22,IF(C1=2008,24)))* N1


Following the paradigm of the first example, you should be able to
simplifiy the latter example as follows:

=IF(C1<=2006, 16.8, IF(C1<=2007, 22, 24))*N1

But that probably does not solve your problem.

I PUT THIS IN BUT THE RESULT RETURNED FOR 2008 STAYED AT 22
ANY IDEAS ??


Of course, it depends on what is in C1. If you have Excel 2003 or
later, click on ToolsFormula AuditingEvaluate Formula to step
through the formula evaluation. That might help you see the problem.
Off-hand, I do not see any problem with the extended logic of the IF()
expression, even as you wrote it.

(Unless C1 has a value greater than 2007 but less than 2008, which is
expected to be interpreted as the "2008" condition -- that is, your
IF() expression is intended to result in 24.)

p.s. C1 HAS CODE IN THE VISUAL BASIC EDITOR DOES THIS HAVE
TO BE CHANGED TO INCORPOATE THE 2008 VALUE?


That is very real possibility. There is no way for us to know unless
you post the VBA code. Then again, it might be complicated and not
worth our time to dissect. Using the Evaluate Formula tool should
help you see if that is where the problem is.

PS: If you do not have Evaluate Formula (Excel 2000 or earlier, I
believe), you could highlight portions of the formula in the "fx"
function field under the toolbar and use F9 to see how the sub-
expression is evaluated. Personally, I don't like that approach, at
least not as it is implemented in Excel 2003. But apparently it has
been recommended by experts in these NGs.




All times are GMT +1. The time now is 04:52 PM.

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