Help with a cell referencing itself in a formula

Scipo0419

New Member
Joined
Dec 6, 2017
Messages
1
First time posting and tried searching but couldn't find exactly what I'm looking for.

I'm working on a spreadsheet for work where I have current hours and cumulative hours. Is there a way I could have the Cumulative Hours, add the current hours through VBA?

Basically I need:


[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD]Current[/TD]
[TD]Cumulative = Cumulative + Current[/TD]
[/TR]
</tbody>[/TABLE]

Where every time I change the "Current" hours total the Cumulative updates accordingly. This will go down an entire column. I'm not sure if this is possible, but adding it manually increases the chances of errors and I'd like to minimize that as much as possible. Currently our Cumulative looks very similar to: "=80+90+75+85+75.5+95.5+90+80+65...."
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Assuming "Current" is column A and "Cumulative" is column B then right click the sheet name and select "View Code" from the menu. Paste the following:

Code:
Private Const CurrentColumn = "A:A" ' Change as necessary
Private Sub Worksheet_Change(ByVal Target As Range)

Dim changedRange As Range
Dim changedCell As Range

Set changedRange = Application.Intersect(Target, Range(CurrentColumn))
If changedRange Is Nothing Then Exit Sub
For Each changedCell In changedRange
    changedCell.Offset(0, 1).Value = changedCell.Offset(0, 1).Value + changedCell.Value
Next changedCell

End Sub

You can change the "Current" column by changing "A:A" on the first line.

WBD
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,154
Members
453,021
Latest member
Justyna P

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