nested if function

compman

New Member
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

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
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.

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

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

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

Thanks folks. You're wonderful.

Replies
5
Views
130
Replies
2
Views
215
Replies
4
Views
223
Replies
4
Views
394
Replies
0
Views
404

1,196,389
Messages
6,014,999
Members
441,864
Latest member
sweezy40

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?

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

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