Automatically update formulas to include new rows

I have a sheet, titled working, that does a lot of the calculations from other sheets that I will ultimately need on a summary sheet in the future. The problem is, the formulas on the working sheet don't automatically update when I add a new row on the data entry sheet.

Here is a link to download the spreadsheet from my SkyDrive if that will make it any easier (it uses Macros, so you will need to download it):

https://skydrive.live.com/redir.aspx?cid=d18ade3fc16e855a&resid=D18ADE3FC16E855A!9361&parid=D18ADE3FC16E855A!117&authkey=!AAC20cqKniiYLco


Any ideas?
Answer
Answer

I see that there is some worksheet code in it, but there is an empty code module.  But not needed.

You can use the INDIRECT() and COUNTA() functions in your formulas on the [Working] worksheet to create dynamic formulas:

In B1 you have:  =SUM('Company A'!G3:G3)

Now, a couple of assumptions are made with the following: that G1 is empty, so we must account for it when we do the COUNTA() operation; and that entries in column G and the others will not have empty rows in the data area of the sheet.

Try this in C1 as a replacement for B1's formula:

=SUM(INDIRECT("'Company A'!G3:G"&COUNTA('Company A'!G:G)+1))

We have made a "constant" value out of the

'Company A'!G3:G 

part of the original formula, and then use the COUNTA(G:G) to count all entries in column G and add 1 to that result to account for the empty G1 cell.  As you add entries into column G on the [Company A] sheet, that COUNTA(G:G) value is going to increase, making for a dynamic formula.

You can similarly modify all other formulas to get their exact range.

But I would also consider the two recommendations that Hans_V put up: of using "oversized" range references.  With the entire column type of reference (as =SUM('Company A'!G:G) ] there is the potential for a performance hit, so his first suggestion of picking a large range that is sufficient to capture all expected entries on a sheet would be the better choice.  I'd start with a guestimate of the maximum number of entries on a 'Company' type sheet and double it and as time goes on and you can examine actual number of entries you could even tweak that number down to one with a 'safe' overhead, but without so much overhead as to affect performance to an unacceptable level.

OR go with my suggestion to get exact ranges to work with, with the slight overhead of using COUNTA() and INDIRECT() a couple of dozen times on a sheet.

I am free because I know that I alone am morally responsible for everything I do. R.A. Heinlein

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated March 30, 2024 Views 7,031 Applies to: