0 votes
in VBA by Beginner (5 points)
I have a excel spreedsheet that has totals that do not get updated when I insert a new row of data. I need to manually change 8 different totals manually once a new row is added. An example would be the formula  "=D280-D283" which is in my total information but the "D280" row is not in my total row.. Each time I add a new row the "D280" must be manually updated by 1 to "D281". If it is "D281" it would be updated to "D282" etc.Since I am changing totals which move down the page by one with each new row I add, i will need a Relative Reference VBA.

Thanks for any help you can provide.
by Skilled (419 points)
+1

Hi hmblaisdell,

You don't mention what, if anything, happens to the "D283". will the formula become

"=D281-D284"

in other words, is there always a three-cell distance between those?

Also, an example workbook would be helpful, to visualize why D280 is "not in the total row".

Before attempting to use VBA (which seems overly-complicated), can you try any of the following?

  • Convert the D column to a table, then use table references, which are relative. Bonus: the total updates automatically
  • Use the SUM function, with an arbitrarily large ending, SUM(D1:D999)
  • A combination of COUNT and SUM functions, for subtraction and other totals.

If VBA is needed, would you want the total triggered each time the sheet changes, or would you prefer to click a button to refresh all totals at once?

 

Cheers,

 

Mitch

by Beginner (5 points)
Mitch

I have created an example spreadsheet with my problem but I cannot figure out how to attach it to an email. Any suggestions?

Harold
by Skilled (419 points)
Hi Harold,

Sorry for the late reply. Are you able to take screen shots of the worksheet? Windows has a Snip tool, or you could use any free screen capture software. If you can "annotate" the worksheet, either in Excel itself or via the screen capture tool, that would help us.

@Ryan Are we allowed to upload workbooks as attachments?

 

Cheers,

 

Mitch
by Beginner (5 points)
Mitch

I have my problem fixed. I completely erased my totals and made these totals part of my original VBA code. Keep in mind that I do not know VBA, I just created a relative reference macro. So now when I add a new line to the macro, the totals are completely erased and then re-added. Because I used relative reference everything now works properly.

thanks for offering to help

Harold
by Skilled (419 points)
You're welcome. I'm glad you were able to solve your challenge.

1 Answer

0 votes
by Super Expert (3.2k points)
 
Best answer

This question is being marked "Answered" based on this comment.

Welcome to wellsr Q&A
wellsr Q&A is the VBA and Python programming community that rewards you for learning how to code.

Getting Started
Register
VBA Cheat Sheets (On Sale Now)

Earn free prizes for asking VBA and Python questions and for answering questions asked by others in our community.

Looking for something else? Hire our professional VBA Help, instead.

What makes us different?
Our points system rewards you with a chance for free gifts based on the quality of your questions and answers. All you have to do is post and you could get rewarded, like these members:

ParserMonster $25 Amazon Gift Card
Hightree $10 Amazon Gift Card
Thales1 $10 Amazon Gift Card
runfunke $10 Amazon Gift Card
coolag $10 Amazon Gift Card
Siew Hun $10 Amazon Gift Card

So, why don't you join us? It really is an encouraging way to motivate members in our VBA and Python community.

Register

For more programming tips visit the VBA Tutorials Blog and the Python Tutorials Blog.

...