How to keep a running 5 cell total

PlumGr8

Board Regular
Joined
Nov 23, 2017
Messages
136
Wasn't sure the best way to word it. But i am tryign to find a way to create and "average" of our hours over the past 5 or 10 deliveries, but also auto updates. we have a prior hours, driven hours then total hours. Say B11, 12, 13. So B11 would show 1000 hrs, B12 would say 15 hours, B13 would show 1015 hours. Every day we update the hours in B12 for todays value. But is there a way to keep a running previous total? Like the last 5 days say B6 - B10 will keep the most recent enteries while deleteing the previous enteries? We do this on another sheet to get an averge time per truck, but trying to see if i can combine it all on to 1 page.
 
Code adjusted to ignore rows less than 12.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Row Mod 4 = 0 And Target.Column = 2 And Target.Row > 11 And Target.Count <= 1 Then
    Cells(9, (Target.Row / 4) + 10).Value = Cells(8, (Target.Row / 4) + 10).Value
    Cells(8, (Target.Row / 4) + 10).Value = Cells(7, (Target.Row / 4) + 10).Value
    Cells(7, (Target.Row / 4) + 10).Value = Cells(6, (Target.Row / 4) + 10).Value
    Cells(6, (Target.Row / 4) + 10).Value = Cells(5, (Target.Row / 4) + 10).Value
    Cells(5, (Target.Row / 4) + 10).Value = Cells(Target.Row, 2).Value
Else
    GoTo ReEnableEvents
End If
ReEnableEvents:
Application.EnableEvents = True
End Sub
I did just try that one as well that one is also good, as long as people keep the row formatting the same. But we also have a notes section after all this stuff, around row 100 or so. Unless there is a way to stop below a certain row?
 
Upvote 0

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
I did just try that one as well that one is also good, as long as people keep the row formatting the same. But we also have a notes section after all this stuff, around row 100 or so. Unless there is a way to stop below a certain row?
Absolutely, the code can be adjusted to account for any limits you would like to add.
 
Upvote 0

Forum statistics

Threads
1,215,089
Messages
6,123,058
Members
449,091
Latest member
ikke

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