# Re: Trying to work out a formula for time lost/gained

joeu2004
Guest
Posts: n/a

 16th Aug 2012
"Laurr456" <(E-Mail Removed)> wrote:
> I have managed to get the credit/debit part of my
> sheet working, now i'm just bamboozled by the running
> balance part..as it starts with a minus figure.
> I need to know how to make it so when I have a credit
> the balance goes down and a debit makes the balance
> go up..?

Referring to http://www.excelbanter.com/attachmen...tachmentid=541,
which you mention in another posting in this thread....

That will be easy. But first, you need to tell us:

1. What are the units of -12.00? Hours? The values in the credit and debit
are Excel times (hh:mm). But -12.00 is a decimal number.

2. Should the -12.00 be on a line by itself before the first line of data.
That is, after line 2, but before line 3? Otherwise, I can we subtract/add
the first credit/debit?

Assuming -12.00 represents hours, it is in J3, and the data starts in row 4,
the formula in J4 might be:

=J3 + IF(H4<>"",H4*24,IF(I4<>"",-I4*24,0))

Some other observations:

3. The formula in G3 is =SUM(F3-D3-E3). There is no point in using the SUM
function there. Simply write =F3-D3-E3.

However, I think it would be prudent to write =--TEXT(F3-D3-E3,"hh:mm"),
since you compare values in column G with "constant" times of the form
TIME(7,24,0).

The double-negative (--) converts text to numeric time. The TEXT function
effectively rounds to the minute. It is necessary to eliminate arithmetic
anomalies that creep into Excel computations. These cause infinitesimal
differences with equivalent constants. So theoretically at least, it is
possible for G3 to display as 7:24, but G3>TIME(7,24,0) or G3<TIME(7,24,0)
might be true.

4. I would write TIME(7,24,0) instead of TIME(7,24,). I know: the two are
equivalent. But IMHO, it is error-prone to omit seconds in that manner. In
fact, it seems to be an accident of implementation that the omission is
interpreted as zero. I do not see that allowed in the TIME help page. I

joeu2004
Guest
Posts: n/a

 16th Aug 2012
Errata.... I wrote:
> Assuming -12.00 represents hours, it is in J3, and the
> data starts in row 4, the formula in J4 might be: =J3 +
> IF(H4<>"",H4*24,IF(I4<>"",-I4*24,0))

Just notice that you have a "break" -- a blank row between weeks. To make
it easy to copy the formula down, do the following:

=IF(G4="","",IF(J3="",J2,J3)+IF(H4<>"",H4*24,IF(I4<>"",-I4*24,0)))

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Claus Busch Microsoft Excel New Users 1 13th Aug 2012 09:00 PM =?Utf-8?B?UmFuZ2VyIE5pZ2U=?= Microsoft Excel Misc 2 31st Jul 2007 10:13 AM PamelaB Microsoft Excel Programming 0 12th Dec 2006 06:05 PM Eric Cadwell Microsoft Dot NET 1 25th Sep 2006 12:16 PM Niceven Microsoft Excel Misc 2 28th May 2004 04:31 PM

Features