nested if function

compman

New Member
Joined
Aug 26, 2002
Messages
9
What is the syntax needed to perform 2 or more IF statements? For example, if in one cell, there are 4 possible entries, and you want to match them to certain values, is it possible? Let's say in cell A1, one can enter the values 1,2,3,or 4. In B1 you want to write an equation that will give you an assigned value for each one. 1=100,2=200,3=300,or 4= 400. How is that done?
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
This syntax is as follows:

=IF(A1=1,100,IF(A1=2,200,IF(A1=3,300,IF(A1=4,400))))

However you may want to look at writing the function in code and passing A1 to it then using Select Case to determine the return value.
 
Upvote 0
On 2002-08-27 07:46, compman wrote:
What is the syntax needed to perform 2 or more IF statements? For example, if in one cell, there are 4 possible entries, and you want to match them to certain values, is it possible? Let's say in cell A1, one can enter the values 1,2,3,or 4. In B1 you want to write an equation that will give you an assigned value for each one. 1=100,2=200,3=300,or 4= 400. How is that done?
Hi compman and welcome to the board.

in B1 you enter:

=IF(A1=1,100,IF(A1=2,200,IF(A1=3,300,400)))

But no more then 7 nests.

VLOOKUP function though is a better choise here.

Eli
 
Upvote 0
If your values are in fact, 1,2,3,etc. You can use the CHOOSE Function

=CHOOSE(A1,100,200,300,...)
 
Upvote 0

Forum statistics

Threads
1,223,286
Messages
6,171,188
Members
452,390
Latest member
kemafa77

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top