Forum Discussion
Not sure how to do a balance sheet on excel
- Sep 21, 2022
rainbowprickles Thanks for sharing.
I made a minor tweak to the formula entered in H7, because it is in a table you shouldn't have to re-enter it as new rows are added.
=IF(C7="income",IFERROR(H6+G7,G7),IFERROR(H6-G7,G7))
Another minor tweak to the current balance:
=OFFSET(H6,COUNTA(H:H)-1,0)
Here is a screen shot showing the ranges the running balance utilizes:
And here is the formula in action showing both the running balance and the current balance being updated as new records are entered/modified:
Hope this helps.
Let me know of any other questions. Revised workbook is attached.
Dexter
https://1drv.ms/x/s!Agw6dWGNwj0JnFN6xR320-KHPIZD?e=WIblem
rainbowprickles Thanks for sharing.
I made a minor tweak to the formula entered in H7, because it is in a table you shouldn't have to re-enter it as new rows are added.
=IF(C7="income",IFERROR(H6+G7,G7),IFERROR(H6-G7,G7))
Another minor tweak to the current balance:
=OFFSET(H6,COUNTA(H:H)-1,0)
Here is a screen shot showing the ranges the running balance utilizes:
And here is the formula in action showing both the running balance and the current balance being updated as new records are entered/modified:
Hope this helps.
Let me know of any other questions. Revised workbook is attached.
Dexter
- rainbowpricklesSep 21, 2022Copper ContributorThank you so much, it's working out so well now! I was just wondering if you could explain the formulas? I'd like to learn how to do it on my own for future references.
- DexterG_IIISep 21, 2022Iron Contributor
rainbowprickles My pleasure.
The if formula is very commonly used.
=If(
condition to evaluate,
value to return if the condition is true,
value to return if the condition if false
)
In your case if the value in cell C7 is "income" then return the previous balance in the running total and add the amount in G7. Otherwise, return the previous balance in the running total and subtract the amount in G7.
=IF(C7="income",IFERROR(H6+G7,G7),IFERROR(H6-G7,G7))
The IFERROR formula is similar in nature but it's condition is already implied. In this case, if the formula H6+G7 returns an error, then use the value in G7 instead. The only time I expect an error is in the very first row because it is trying to add the text header "Running Balance" to a number which doesn't work too well. So, our starting balance will always be determined by the first row. Perhaps inserting a row above row 7 is appropriate and ensure the value in G7 is, indeed, the starting balance.
The next formula is not as common, but useful in managing references to ranges which are always growing and/or shrinking, particularly if they are not inside a table object. It actually receives up to 5 inputs, although only 3 are used in your example
=OFFSET(H6,COUNTA(H:H)-1,0)
=OFFSET(
- Starting Cell Reference,
- Number of rows to move from the Starting Cell Reference (positive values will move down, negative values up, and a 0 will not move at all),
- Number of columns to offset (just like rows except left or right of the Starting Cell Reference)
- (not used in your situation) The height of the offset. This changes the offset from being a reference to a single cell to being a reference to a range of cells. Similar to step 2 you can calculate how many rows contain data in order to determine the range height.
- (not used in your situation) The width of the offset. Just like step 4 except it extends the range left or right instead of up or down
)
So in your case, the Starting Cell Reference was H6 or the header "Running Balance". To determine how many rows to offset, we count the number of cells with data in column H using COUNTA(H:H). There are 8 cells containing data and we subtract one for the header row. Therefor the formula starts with H6 and moves 7 rows down which is row 13.
But lets say we wanted to sum the values in the amount column we would use
=OFFSET(
- G7,
- 0, (we don't want to move any cells this time because G7 should be the beginning of our range)
- 0, (again, don't want to move cells)
- COUNTA(G:G), -2 this counts the cells containing data but we need to subtract 2 to account for both the header row (G6 and the value in H3)
- 1 (we want the range to be only 1 column wide)
)
This would evaluate to be cells G7:G13. And if we wanted to sum the values in that range we would simply wrap the offset formula inside a SUM() formula. I said particularly for ranges not within a table object because you can apply a formula to a table range and it will always grow or shrink according to how many rows are in the table by referring to Table_Name[Header_Name] instead of normal cell references.
Hope this clarifies and glad to help.
Dexter