Please see the sample sheet
When you click on the command button the total is taken horizontally and vertically and written in their proper column.
for Vertical total is taken from D7:D9 till the end of the column.
For horizontal total is taken from D7:O7 for all 3 rows.
If you now insert a row then the total is taken from D8:D10 where as I require from D7:D10
Same if you insert a column.
If you delete the column for formula should also change accordingly.
The rows and columns changes frequently so the last row and column should be taken into account
I hope the explanation is clear