ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Time Calculation returning 19:00 (https://www.excelbanter.com/excel-discussion-misc-queries/227874-time-calculation-returning-19-00-a.html)

default time to PM after 12:00 pm[_2_]

Time Calculation returning 19:00
 
I'm trying to calculate the hh:mm difference between two cells and asking to
do nothing if W1 is blank. Why am I getting 19:00 as a value from a
calculation of:

=IF(W1<X1,X1-W1,IF(W1="","",IF(W1X1,"","")))

JLatham

Time Calculation returning 19:00
 
Difficult to answer without knowing what values are actually in X1/W1 when
you are getting th 19:00 result.

In the meantime, I think you can simplify your formula to:
=IF(W1="","w1 empty",IF(W1<X1,X1-W1,""))
or (to put it more like yours is now)
=IF(W1="","",IF(W1<X1,X1-W1,""))

"default time to PM after 12:00 pm" wrote:

I'm trying to calculate the hh:mm difference between two cells and asking to
do nothing if W1 is blank. Why am I getting 19:00 as a value from a
calculation of:

=IF(W1<X1,X1-W1,IF(W1="","",IF(W1X1,"","")))


joeu2004

Time Calculation returning 19:00
 
"default time to PM after 12:00 pm"
. com wrote:
I'm trying to calculate the hh:mm difference between two cells
and asking to do nothing if W1 is blank. Why am I getting 19:00
as a value from a calculation of:
=IF(W1<X1,X1-W1,IF(W1="","",IF(W1X1,"","")))


I haven't a clue, since your posting does not tell us what is in W1 and X1.
Why shouldn't the formula return 19:00?

But here are some tweaks that you should consider for your formula. It
might solve the problem coincidentally.

First, if W1 is empty (not ""), your formula will return X1 because W1<X1 is
true. I suspect that is not what you want.

Second, the last term (if W1X1,...) is superfluous, albeit not harmful.

Third, you assume that X1 cannot be empty or null text (""). Is that a
valid assumption?

At a minimum, try:

=if(and(W1<"",W1<X1),X1-W1,"")

Alternatively:

=if(and(W1<"",X1<"",W1<X1),X1-W1,"")



All times are GMT +1. The time now is 12:42 PM.

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