# How can a logical test equal one cell?

#### Mtyler

##### Board Regular
I'm confused.

I'm reviewing someone else's work and they have used the following if formula

=+IF(D15,D15/E15-1,"")

Cell D15 does not contain anything other than a hard coded number.

Surely this if function is useless, even if D15 contains nothing?

Thanks

Matt

### Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

#### Jonmo1

##### MrExcel MVP
As far as excel is concerned,
0 (or Blank) = FALSE
ANY OTHER NUMBER = TRUE

Hope this helps...

#### Geoff Taylor

##### Active Member
The one effect I can see is that a zero result is not displayed as "0", but as a blank.

#### Jonmo1

##### MrExcel MVP
Surely this if function is useless

Most definately NOT useless...

Say you want to Devide B1/A1
=B1/A1
But if A1 is Blank or 0, you get #DIV/0! Error

Some would use
=If(Iserror(B1/A1),"",B1/A1)
to account for that...

But it is much easier to do this instead

=If(A1,B1/A1,"")

Last edited:

#### Mtyler

##### Board Regular
Thanks for your replies...

So, If(D5,.... essentially removes any errors that may result from the logical test cell being 0 or blank.

I see.

Thank you!

#### Geoff Taylor

##### Active Member
Hi Jonmo,
This formula isn't suppressing a division by zero error. Look again; it's testing the numerator, not the demoninator.

#### Jonmo1

##### MrExcel MVP
You'd better check again Geoff....

the number to the RIGHT of the / is the number that causes #DIV/0 Errors.

#### Geoff Taylor

##### Active Member
Yes, the number to the RIGHT is the one that causes the error, but in the formula the number to the LEFT is the one being tested, so the formula can't be a test for a DIV/0 error.

Or am I just being thick?

#### Jonmo1

##### MrExcel MVP
VISUALLY in the spreadsheet, yes A1 is to the LEFT of B1...

But in my example Formula, it's the other way around..

B1/A1

#### Geoff Taylor

##### Active Member
I'm definitely being thick, but bear with me...

In the formula posted at the top of the thread, the logic is "If D15's got something in it, divide it by E15 and then take away 1". In that formula, E15 would be the one causing the DIV/0 error, so why test D15?

Replies
20
Views
604
Replies
15
Views
310
Replies
4
Views
324
Replies
1
Views
187
Replies
1
Views
149

Threads
1,191,579
Messages
5,987,425
Members
440,096
Latest member
yanaungmyint

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

### Disable AdBlock

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

### Disable AdBlock Plus

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