ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Running Totals Formulas (https://www.excelbanter.com/excel-programming/344635-running-totals-formulas.html)

Jaime

Running Totals Formulas
 
I am trying to figure out a macro or a formula that will allow me to keep a
running total when one cell in the formula is constantly changing.

Example:

Cell B6 contains the number 7 (total for this week)
Cell B35 contains the number 36 (year to date total including the 7 for this
week)

I want to be able to change cell B6 and have the new amount added to the 36
in cell B35 and the answer to that total, replace the year to date total in
Cell B35.

So, if cell B6 changes to 9 (total for the week) then I want the B35 total
to change to the 36 year to date pluse the 9 for the new weekly total and
ultimately replace the B35 cell number of 36 with the answer which is 45.

Does anyone know how I can do this?

Jim Thomlinson[_4_]

Running Totals Formulas
 
Here is some code for you. At each change in Cell B6, it adds the value of B6
to the existing value of B35 to make a new total in B35. Right click on the
sheet tabe where you want the code and select view code (this can not be in a
regular module) and add this code...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$6" Then
Range("B35").Value = Range("B35").Value + Target.Value
End If
End Sub
--
HTH...

Jim Thomlinson


"Jaime" wrote:

I am trying to figure out a macro or a formula that will allow me to keep a
running total when one cell in the formula is constantly changing.

Example:

Cell B6 contains the number 7 (total for this week)
Cell B35 contains the number 36 (year to date total including the 7 for this
week)

I want to be able to change cell B6 and have the new amount added to the 36
in cell B35 and the answer to that total, replace the year to date total in
Cell B35.

So, if cell B6 changes to 9 (total for the week) then I want the B35 total
to change to the 36 year to date pluse the 9 for the new weekly total and
ultimately replace the B35 cell number of 36 with the answer which is 45.

Does anyone know how I can do this?


Jaime

Running Totals Formulas
 
Thank you! Thank you! Thank you!

This makes my job a TON easier.

"Jim Thomlinson" wrote:

Here is some code for you. At each change in Cell B6, it adds the value of B6
to the existing value of B35 to make a new total in B35. Right click on the
sheet tabe where you want the code and select view code (this can not be in a
regular module) and add this code...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$6" Then
Range("B35").Value = Range("B35").Value + Target.Value
End If
End Sub
--
HTH...

Jim Thomlinson


"Jaime" wrote:

I am trying to figure out a macro or a formula that will allow me to keep a
running total when one cell in the formula is constantly changing.

Example:

Cell B6 contains the number 7 (total for this week)
Cell B35 contains the number 36 (year to date total including the 7 for this
week)

I want to be able to change cell B6 and have the new amount added to the 36
in cell B35 and the answer to that total, replace the year to date total in
Cell B35.

So, if cell B6 changes to 9 (total for the week) then I want the B35 total
to change to the 36 year to date pluse the 9 for the new weekly total and
ultimately replace the B35 cell number of 36 with the answer which is 45.

Does anyone know how I can do this?



All times are GMT +1. The time now is 03:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com