# If statement

#### abee4life

##### Active Member
Can someone help with an If statement please.

I have tried different variations of how to do what I want, but nothing seems to work.

I want in C1 a formula that tells me if A1 and B1 are the same and if so to return the number 1, if its not then 0. Now, I know the the basic formula would be =if(a1=b1,1,0) but it returns a 1 even if the two cells are empty.

What I want is for C1 to tell me 0 if the cells are blank, or do not have the same numbers as each other. Can someone help please.

### Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

##### MrExcel MVP
Can someone help with an If statement please.

I have tried different variations of how to do what I want, but nothing seems to work.

I want in C1 a formula that tells me if A1 and B1 are the same and if so to return the number 1, if its not then 0. Now, I know the the basic formula would be =if(a1=b1,1,0) but it returns a 1 even if the two cells are empty.

What I want is for C1 to tell me 0 if the cells are blank, or do not have the same numbers as each other. Can someone help please.

Assumes numeric entries...

=IF(COUNT(A1:B1)=2,IF(A1=B1,1,0),0)

#### nise23

##### Board Regular
=if(and(a1=b1, not(and(isblank(a1),isblank(b1)))),1,0)

Try
=COUNTIF(A1,B1)

Many thanks guys

Replies
3
Views
22
Replies
1
Views
91
Replies
1
Views
66
Replies
6
Views
154
Replies
3
Views
38

1,130,118
Messages
5,640,211
Members
417,131
Latest member
Seanr19871

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