ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   How do I stop Excel from treating blank cells as zero? (https://www.excelbanter.com/excel-worksheet-functions/45105-how-do-i-stop-excel-treating-blank-cells-zero.html)

Michael Gillie

How do I stop Excel from treating blank cells as zero?
 
I'm calculating the difference between two dates, such as

A1 - 1st September
B1 - 10th September

So B1-A1 returns 9, which is great.

But I only enter the dates in column B when a certain visit has been made,
and while the cells in B are blank, Excel treats them as zero (or 1st Januray
1900). So B1-A1 returns -39000 odd.

Is there a way to essentially stop it from calculating the formula until
both cells have a value entered?

Roger Govier

Hi Michael
Try
=IF(OR(A1="",B1=""),"",B1-A1)

Regards

Roger Govier


Michael Gillie wrote:
I'm calculating the difference between two dates, such as

A1 - 1st September
B1 - 10th September

So B1-A1 returns 9, which is great.

But I only enter the dates in column B when a certain visit has been made,
and while the cells in B are blank, Excel treats them as zero (or 1st Januray
1900). So B1-A1 returns -39000 odd.

Is there a way to essentially stop it from calculating the formula until
both cells have a value entered?


Anirudh

Hi Michael,

Pls try this

=IF(a7=" ",,a7-a7)



"Michael Gillie" wrote:

I'm calculating the difference between two dates, such as

A1 - 1st September
B1 - 10th September

So B1-A1 returns 9, which is great.

But I only enter the dates in column B when a certain visit has been made,
and while the cells in B are blank, Excel treats them as zero (or 1st Januray
1900). So B1-A1 returns -39000 odd.

Is there a way to essentially stop it from calculating the formula until
both cells have a value entered?



All times are GMT +1. The time now is 10:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com