Microsoft KB Archive/134322

Mac Works: Using Nested IF Statements

PSS ID Number: Q134322 Article last modified on 10-22-1998

1.xx 2.xx 3.xx 4.0 4.0a 4.0b

MACINTOSH

=
=========================================================

= SUMMARY =

The syntax of an IF function is as follows:

IF(Condition,ValueIfTrue,ValueIfFalse).

You can also nest, or add, another ValueIfTrue or ValueIfFalse IF function to the statement thereby adding more conditions to test on. See below for an example of a Nested IF Statement.

= MORE INFORMATION =

Below is an example of using a nest IF statement:

Cell A2 of the spreadsheet has a value between 1 and 40, and Cell B2 has a percentage rate which is based on the value in A2. If the value in A2 is between 1-10, B2 should be 8%, or .08. If the value in A2 is 11-20, the B2 percentage should be .07, and so on.

The following is an example of a formula to use in cell B2:

=IF(A2<11,.08,IF(A2<21,.07,IF(A2<31,.06,IF(A2<=40,.05,0))))

In this example, the overall IF statement A2<11 is checked first, and if the result is true, .08 is displayed in the cell. If the result of that condition is false, it proceeds to the next IF statement to test its condition, and so on. For example, your spreadsheet might resemble the following:

A     B 1 2 4 .08 3 23 .06 4 11 .07 5 42 0

KBCategory: kbusage KBSubcategory: mwksss macworkskb

Additional reference words: kbhowto 1.xx 2.xx 3.xx 4.00 4.00a 4.00b mac m_works

=
========================================================= Version : 1.xx 2.xx 3.xx 4.0 4.0a 4.0b Platform : MACINTOSH ============================================================================= Copyright Microsoft Corporation 1998.