Trouble with getting correct formula in Calc?

3 Columns are involved.
| Debit (D) | Credit (E) | Balance (H) |

I want H3 to have C3 deducted and if there is a number in E3, that wants adding to in H3.
At any time there will only be one number in either D3 or E3, there will never be numbers in both cells together.
I have been trying something like =IF(D3>0, H2-D3,""),IF(E3>0,H2+E3,"")) Where H2 is the last Balance number.
The formula is to be placed in H3. What am I doing wrong? Thanks, altv84

Please upload a sample file here, in which the problem is present.

To upload:
Click on the three dots ( … ) directly below your inktial question.
Then click the pencil icon to edit your question.
In question edit mode, select the upload icon. 202108_DE  Symbol Hochladen

Select your file and click the Upload button.

EarnestAI,
I have started using that formula which is doing what I want it to, but, When I copy it down the H column, I notice that when there are no figures in D or E, Column H has the last set of numbers in all the cells I have copied the formula to. There must be some way, of conditionaly formatting the column to leave the “unused” cells blank. Have looked in Conditional Formatting and used the Blank but it still showed all the figures in the Column.
Is there some quirk I need to do to get the column to be blank until I feed it with numbers in D or E?

Thanks for your help.

I think you are over-complicating it. Where H2 is previous balance then enter in H3
=H2+D3-E3

EarnestAl, Thanks for that. The + and - are in the wrong place for me, they want reversing, but that aside, it gives me exactly what I wanted.Take care! altv84.

Whoops! Rush job :open_mouth:

EarnestAI,
I have started using that formula which is doing what I want it to, but, When I copy it down the H column, I notice that when there are no figures in D or E, Column H has the last set of numbers in all the cells I have copied the formula to. There must be some way, of conditionaly formatting the column to leave the “unused” cells blank. Have looked in Conditional Formatting and used the Blank but it still showed all the figures in the Column.
Is there some quirk I need to do to get the column to be blank until I feed it with numbers in D or E?

Thanks for your help.

That is for future entries I guess. Normally, there would be a date column or some other necessary column such as transaction number that could be roped in as the check for the If statement. In the absence of that then I would use a formula like this:
=IF(AND(ISBLANK(D3);ISBLANK(E3));"";H2-D3+E3)
Just don’t copy it to the initial balance in H2.
The AND will only be true if both D3 and E3 are true. If the AND is true then "" returns a blank cell, else the addition formula applies.
If you have a required field such as Date in column A then it could be shortened to
=IF(ISBLANK(A3);"";H2-D3+E3)
Others might have a more elegant or concise method

EarnestAI
Many thanks. I had a look at the ISBLANK system but couldn’t get it to work. I then looked At a sheet I had from a previous existence and tried a formula from that and again, I couldn’t get it to function correctly. But when I tried the ones you have just sent in, they worked a treat. It is so many years that I used to do this sort of thing and now I am trying to do it for the fun of doing it!! Memory is a wonderful thing!

In my earlier sheet, the formula I have leaves the cells blank until such time as other cells are populated. But I had difficulty in adjusting those formulae to suit the present application.

Again many thanks for your help. As the man once said, “Now are cooking by gas!”

altv84

The help system describes Functions fairly tersely but where there is an example of how a function could be used, that is gold.
The function wizard (fx next to formula bar) can be helpful in constructing your formula. But it is true, you do need to know what a function can do before you can look it up in help. An internet search can be helpful if you can describe the problem succinctly.
For a little bedtime reading the Calc Guide, downloadable from English documentation | LibreOffice Documentation - Your documentation for LibreOffice, has a more structured approach and is worth reading.
Good luck. Cheers, Al