Running Totals

freddie mitchell

New Member
Joined
Apr 14, 2011
Messages
43
I would like to create a running total for a single cell which then adds up in another!
Example I add "4" to cell b5 this then appears in cell b6. I then add "5" to cell b5 then "9" apperas in b6

How would I get this to work.
Thankyou so much for any assitance freddie
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Row = 5 And Target.Cells.Column = 2 Then
    Cells(6, 2) = Cells(5, 2) + Cells(6, 2)
End If
End Sub

This will look at B5 and on each change, it will add that value to the value in B6... Hope that helps...
 
Upvote 0
Thankyou so much! would I just copy it if I wanted to do it for multiple examples? Also me being stupid but how do I change the cell numbers ive tired a few times but no luck!
 
Upvote 0
The ROW numbers are the same and the columns are numeric for the letter.

IE: A5 = Row 5, Column 1
F10 = Row 10, Column 6

You can put that macro in the sheet that you want it to work with and the IF... THEN will need to be modified for each Row/Column Combination you want...

In my example:

Code:
If Target.Cells.Row = 5 And Target.Cells.Column = 2 Then

That is checking B5 for a change. For F6 you would use

Code:
If Target.Cells.Row = 6 And Target.Cells.Column = 6 Then

Make sense?

If you are looking to watch BOTH cells for changes, the code would be

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Watch B5 for Changes, Running total in B6
If Target.Cells.Row = 5 And Target.Cells.Column = 2 Then
    Cells(6, 2) = Cells(5, 2) + Cells(6, 2)
End If
'Watch F6 for Changes, Running total in F7
If Target.Cells.Row = 6 And Target.Cells.Column = 6 Then
    Cells(7, 6) = Cells(6, 6) + Cells(7, 6)
End If
End Sub

That answer your question?
 
Upvote 0
Thankyou for the name changing I almost got it right :P!! But how do actaully copy the formula and use it on the same spreadsheet (right now its telling me that theres an amigious name ending) Thankyou
 
Upvote 0
This is not a formula, this is a macro.

The macro is a OnChange macro, so whenever data is changed in the sheet, it triggers the macro, that is why there is that If the cells is a certain row and column, then do something, otherwise ignore.

I assumed you would want to watch multiple cells, so that is why I added that last example in my previous post.

This will be placed in the VBE (Visual Basic Environment). You can get there by pressing ALT-F11.
 
Upvote 0
I now have another problem! is there any way of connecting an excel document with word! i.e. someone rights somethin g in a text box on excel then they press return and it gets moved to a word document? thanks for any assitance
 
Upvote 0
That is something I never thought of doing and quite frankly, don't think it it possible. If someone else knows how, then they are a better man than me.

Why, if I may ask, are you looking to do that? I think you may be able to do something similiar with a Mail Merge feature where you setup a field in the word doc that pulls from an Excel sheet, but I don't believe it is dynamic.

Good luck with that one... =)
 
Upvote 0

Forum statistics

Threads
1,224,513
Messages
6,179,214
Members
452,895
Latest member
BILLING GUY

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top