# 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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

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

Replies
10
Views
85
Replies
1
Views
61
Replies
1
Views
23
Replies
5
Views
110
Replies
9
Views
113