# multiple if-and function

#### leah_v

##### New Member
I am new to excel. I am trying to write a function with 3 conditions, but it does not work. Could you please help me to figure out what error I do?

=IF(AND(A1=1, ISBLANK(B1)),C1=1,IF(AND(A1=2, B1=1),C1=2,IF(AND(A1=2, B1=2),C1=0)))

What I am trying to say: if in column A value is 1 and column B is empty cell, then C should be 1, if column A is 2 and Coulmn B is 1, then C should be 2. Finally, if both columns are 2 then C should be 0.

Last edited:

### Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
I am new to excel. I am trying to write a function with 3 conditions, but it does not work. Could you please help me to figure out what error I do?

=IF(AND(A1=1, ISBLANK(B1)),C1=1,IF(AND(A1=2, B1=1),C1=2,IF(AND(A1=2, B1=2),C1=0)))

What I am trying to say: if in column A value is 1 and column B is empty cell, then C should be 1, if column A is 2 and Coulmn B is 1, then C should be 2. Finally, if both columns are 2 then C should be 0.

This formula entered in C1:

=IF(AND(A1=1,B1=""),1,IF(AND(A1=2,B1=1),2,IF(AND(A1=2,B1=2),0,"")))

It worked just fine! Many-many thanks. T. Valko, for your time. I still try to see what wrong I did, so taht I learn something. Was the problem in referreing to the column C, while I needed just to put the value?

It worked just fine! Many-many thanks. T. Valko, for your time. I still try to see what wrong I did, so taht I learn something. Was the problem in referreing to the column C, while I needed just to put the value?
Yes, that was the problem.

Also, at the very end of the formula you needed to define what to return if NONE of the conditions was met. I have the formula return a blank "".

Got it--thank you! I learned something new today. Have a great day!

Got it--thank you! I learned something new today. Have a great day!
You're welcome. Thanks for the feedback!

Replies
25
Views
516
Replies
10
Views
612
Replies
16
Views
480
Replies
1
Views
257
Replies
12
Views
403

1,203,072
Messages
6,053,377
Members
444,659
Latest member
vuphihung

### 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.

### Which adblocker are you using?

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

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