Looking to create a sum and a count formula that will automatically adjust itself for new rows that are inserted within the range.
For example if I have the formula in cell D55 =SUM(D17:D54)
. Every time I insert a new row within that range, I need to change the top range of my formula to account for it.
Is there a way to write a formula that will automatically adjust itself, so that every time I add a new row I will not need to change my summation formula?
1. Enter this formula: =SUM(INDIRECT("D2:D"&ROW()-1)) (D2 is the first cell in the list that you want to sum) at the end of the cells that you want to sum the number list, and press Enter key. Tips: The formula only work correctly when you place it at the end of the data list.
Simply do the following: Select the cell with the formula and the adjacent cells you want to fill. Click Home > Fill, and choose either Down, Right, Up, or Left. Keyboard shortcut: You can also press Ctrl+D to fill the formula down in a column, or Ctrl+R to fill the formula to the right in a row.
Select a cell next to the numbers you want to sum, click AutoSum on the Home tab, press Enter, and you're done. When you click AutoSum, Excel automatically enters a formula (that uses the SUM function) to sum the numbers.
Try
D55: =SUM(INDIRECT("D17:D"&ROW()-1))
This should dynamically adjust to added rows since when adding rows at row 17 the current value at D17
shifts to D18
and no value is present at D17
. INDIRECT()
should take this into account. ROW()-1
ensures that even when rows are added immediately preceding the formula these are still taken into account.
Edit: I should have added that this can be applied to any formula. Simply replace the range part of your formula with the INDIRECT
.
And a quick explanation: the INDIRECT
creates an Excel reference from a string so you can construct your formula using dynamic objects. The ROW
part of the formula acts as the dynamic factor which is completely dependent on the row count that you add but is independent of the position at which you add your new row.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With