# if & or functions???

#### Elise Nerlove

##### Board Regular
Hi,

I need help with an equation:

If column A = nothing AND column B = nothing, then do nothing. But if a value appears in either column a or b then do the equation: b-a=c

im thinking the equation is: =if(a="",andif(b="","",b-a))

but this is outputting "FALSE" for all rows....any ideas?

Thanks so much for the help!!! greatly appreciated!

### Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

#### prabby25101981

##### Active Member
The formula will be -

=IF(AND(ISBLANK(A1),ISBLANK(B1)),"",B1-A1)

Hope this helps!

#### ljungren13

##### Board Regular
Does this work:

=IF(A1="","",IF(B1="","",B1-A1))

or this:

=IF(AND(A1="",B1=""),"",B1-A1)

depending if i misunderstood you

Last edited:

#### Elise Nerlove

##### Board Regular
Thanks so much!!

prabby, that equation didnt quite work, but ljungren13 your equation worked!!

Problem solved, thanks!

Elise

#### prabby25101981

##### Active Member

Did you want to check if one of A1 or B1 is blank or both blank. In case you wanted to display "" if any of these are blank, then use this -

=IF(OR(ISBLANK(A1),ISBLANK(B1)),"",B1-A1)

#### Scott Huish

##### MrExcel MVP
Why not use COUNT?

=IF(COUNT(A1:B1)=2,B1-A1,"")

#### omicronkappa278

##### New Member

Seems to me that she was looking for an or situation. The Count works great, but maybe like this for OR?

=IF(COUNT(A1:B1)>0,B1-A1,"")

This satisfies the OR in her needs. Seems like if both are BLANK then do nothing and if EITHER has a value then b-a.

cheers,

omicronkappa278
louisiana

#### Scott Huish

##### MrExcel MVP
If it's either, then:

=IF(COUNT(A1:B1),B1-A1,"")

#### omicronkappa278

##### New Member
Ah yes... no need for the ">0" because the if will treat anything greater than 0 as a True right?

#### Scott Huish

##### MrExcel MVP
Yes, specifically any number not equal to 0 will equate to TRUE.

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

1,164,302
Messages
5,836,498
Members
430,436
Latest member
fefenouil

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