Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Rolling Total

Hello,

I have a range of cells for input of hours 8 or 12, these total up in a cell
D1, is there a way of keeping this rolling total in this cell when I delete
the hours I input, so if I input hours 12 into A1, A2, A3 the total in cell
D1 should be 36, when I delete the hours in cells A1, A2 and A3 I want the 36
still to remain in cell D1 and again start totalling when I add further hours
to cell A1, A2, A3 and so on so it stays as a rolling total all the time.

Any help would be much appreciated.

Many thanks


Mark
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Rolling Total

You would need to add something like the following code to the module of the
worksheet you are working in. It will add whatever you type into A1:A3 to D1.

HTH,

Eric

*****
Paste the code below into the worksheet's code module:
*****
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Long, j As Long
Dim nAreas As Long
Dim theCell As Range
'
nAreas = Target.Areas.Count
'
' Since "Target" can have multiple areas selected, we
' need to check each cell in each area to see if it is
' in the range "A1:A3".
'
For i = 1 To nAreas
For Each theCell In Target.Areas(i).Cells
If (Not Intersect(theCell, ActiveSheet.Range("A1:A3")) Is
Nothing) Then
ActiveSheet.Range("D1") = ActiveSheet.Range("D1") + theCell
End If
Next theCell
Next i
'
End Sub

"terilad" wrote:

Hello,

I have a range of cells for input of hours 8 or 12, these total up in a cell
D1, is there a way of keeping this rolling total in this cell when I delete
the hours I input, so if I input hours 12 into A1, A2, A3 the total in cell
D1 should be 36, when I delete the hours in cells A1, A2 and A3 I want the 36
still to remain in cell D1 and again start totalling when I add further hours
to cell A1, A2, A3 and so on so it stays as a rolling total all the time.

Any help would be much appreciated.

Many thanks


Mark

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Rolling Total

On Feb 25, 3:23*pm, terilad wrote:
Hi
You can put the rolling total in E1

Sub TotalIt()
Total = Range("E1").Value
Range("E1").Value = Range("D1").Value + Total
End Sub

run this sub each time you change the numbers in the A column
regards
Paul

Hello,

I have a range of cells for input of hours 8 or 12, these total up in a cell
D1, is there a way of keeping this rolling total in this cell when I delete
the hours I input, so if I input hours 12 into A1, A2, A3 the total in cell
D1 should be 36, when I delete the hours in cells A1, A2 and A3 I want the 36
still to remain in cell D1 and again start totalling when I add further hours
to cell A1, A2, A3 and so on so it stays as a rolling total all the time.

Any help would be much appreciated.

Many thanks

Mark


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Rolling Total

Hi Eric,

This is doing the trick, what do I need to do to add more cells.

e.g. I have A1:A3 to total in D1 I want to add C1:C3 to total in cell E1,
how will this be added to the code.

Many thanks

Mark

"EricG" wrote:

You would need to add something like the following code to the module of the
worksheet you are working in. It will add whatever you type into A1:A3 to D1.

HTH,

Eric

*****
Paste the code below into the worksheet's code module:
*****
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Long, j As Long
Dim nAreas As Long
Dim theCell As Range
'
nAreas = Target.Areas.Count
'
' Since "Target" can have multiple areas selected, we
' need to check each cell in each area to see if it is
' in the range "A1:A3".
'
For i = 1 To nAreas
For Each theCell In Target.Areas(i).Cells
If (Not Intersect(theCell, ActiveSheet.Range("A1:A3")) Is
Nothing) Then
ActiveSheet.Range("D1") = ActiveSheet.Range("D1") + theCell
End If
Next theCell
Next i
'
End Sub

"terilad" wrote:

Hello,

I have a range of cells for input of hours 8 or 12, these total up in a cell
D1, is there a way of keeping this rolling total in this cell when I delete
the hours I input, so if I input hours 12 into A1, A2, A3 the total in cell
D1 should be 36, when I delete the hours in cells A1, A2 and A3 I want the 36
still to remain in cell D1 and again start totalling when I add further hours
to cell A1, A2, A3 and so on so it stays as a rolling total all the time.

Any help would be much appreciated.

Many thanks


Mark

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Rolling Total

Just add one more check to the code:

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Long, j As Long
Dim nAreas As Long
Dim theCell As Range
'
nAreas = Target.Areas.Count
'
' Since "Target" can have multiple areas selected, we
' need to check each cell in each area to see if it is
' in the range "A1:A3" or the range "C1:C3"
'
For i = 1 To nAreas
For Each theCell In Target.Areas(i).Cells
If (Not Intersect(theCell, ActiveSheet.Range("A1:A3")) Is
Nothing) Then
ActiveSheet.Range("D1") = ActiveSheet.Range("D1") + theCell
ElseIf (Not Intersect(theCell, ActiveSheet.Range("C1:C3")) Is
Nothing) Then
ActiveSheet.Range("E1") = ActiveSheet.Range("E1") + theCell
End If
Next theCell
Next i
'
End Sub


"terilad" wrote:

Hi Eric,

This is doing the trick, what do I need to do to add more cells.

e.g. I have A1:A3 to total in D1 I want to add C1:C3 to total in cell E1,
how will this be added to the code.

Many thanks

Mark

"EricG" wrote:

You would need to add something like the following code to the module of the
worksheet you are working in. It will add whatever you type into A1:A3 to D1.

HTH,

Eric

*****
Paste the code below into the worksheet's code module:
*****
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Long, j As Long
Dim nAreas As Long
Dim theCell As Range
'
nAreas = Target.Areas.Count
'
' Since "Target" can have multiple areas selected, we
' need to check each cell in each area to see if it is
' in the range "A1:A3".
'
For i = 1 To nAreas
For Each theCell In Target.Areas(i).Cells
If (Not Intersect(theCell, ActiveSheet.Range("A1:A3")) Is
Nothing) Then
ActiveSheet.Range("D1") = ActiveSheet.Range("D1") + theCell
End If
Next theCell
Next i
'
End Sub

"terilad" wrote:

Hello,

I have a range of cells for input of hours 8 or 12, these total up in a cell
D1, is there a way of keeping this rolling total in this cell when I delete
the hours I input, so if I input hours 12 into A1, A2, A3 the total in cell
D1 should be 36, when I delete the hours in cells A1, A2 and A3 I want the 36
still to remain in cell D1 and again start totalling when I add further hours
to cell A1, A2, A3 and so on so it stays as a rolling total all the time.

Any help would be much appreciated.

Many thanks


Mark



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Rolling Total

Excellant,

many thanks for your help, really much appreciated.

Regards

Mark

"EricG" wrote:

Just add one more check to the code:

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Long, j As Long
Dim nAreas As Long
Dim theCell As Range
'
nAreas = Target.Areas.Count
'
' Since "Target" can have multiple areas selected, we
' need to check each cell in each area to see if it is
' in the range "A1:A3" or the range "C1:C3"
'
For i = 1 To nAreas
For Each theCell In Target.Areas(i).Cells
If (Not Intersect(theCell, ActiveSheet.Range("A1:A3")) Is
Nothing) Then
ActiveSheet.Range("D1") = ActiveSheet.Range("D1") + theCell
ElseIf (Not Intersect(theCell, ActiveSheet.Range("C1:C3")) Is
Nothing) Then
ActiveSheet.Range("E1") = ActiveSheet.Range("E1") + theCell
End If
Next theCell
Next i
'
End Sub


"terilad" wrote:

Hi Eric,

This is doing the trick, what do I need to do to add more cells.

e.g. I have A1:A3 to total in D1 I want to add C1:C3 to total in cell E1,
how will this be added to the code.

Many thanks

Mark

"EricG" wrote:

You would need to add something like the following code to the module of the
worksheet you are working in. It will add whatever you type into A1:A3 to D1.

HTH,

Eric

*****
Paste the code below into the worksheet's code module:
*****
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Long, j As Long
Dim nAreas As Long
Dim theCell As Range
'
nAreas = Target.Areas.Count
'
' Since "Target" can have multiple areas selected, we
' need to check each cell in each area to see if it is
' in the range "A1:A3".
'
For i = 1 To nAreas
For Each theCell In Target.Areas(i).Cells
If (Not Intersect(theCell, ActiveSheet.Range("A1:A3")) Is
Nothing) Then
ActiveSheet.Range("D1") = ActiveSheet.Range("D1") + theCell
End If
Next theCell
Next i
'
End Sub

"terilad" wrote:

Hello,

I have a range of cells for input of hours 8 or 12, these total up in a cell
D1, is there a way of keeping this rolling total in this cell when I delete
the hours I input, so if I input hours 12 into A1, A2, A3 the total in cell
D1 should be 36, when I delete the hours in cells A1, A2 and A3 I want the 36
still to remain in cell D1 and again start totalling when I add further hours
to cell A1, A2, A3 and so on so it stays as a rolling total all the time.

Any help would be much appreciated.

Many thanks


Mark

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Rolling Total

glad to help
Paul


On Feb 26, 5:29*pm, terilad wrote:
Excellant,

many thanks for your help, really much appreciated.

Regards

Mark

"EricG" wrote:
Just add one more check to the code:


Option Explicit


Private Sub Worksheet_Change(ByVal Target As Range)
* * Dim i As Long, j As Long
* * Dim nAreas As Long
* * Dim theCell As Range
'
* * nAreas = Target.Areas.Count
'
' Since "Target" can have multiple areas selected, we
' need to check each cell in each area to see if it is
' in the range "A1:A3" or the range "C1:C3"
'
* * For i = 1 To nAreas
* * * * For Each theCell In Target.Areas(i).Cells
* * * * * * If (Not Intersect(theCell, ActiveSheet.Range("A1:A3")) Is *
Nothing) Then
* * * * * * * * ActiveSheet.Range("D1") = ActiveSheet..Range("D1") + theCell
* * * * * * ElseIf (Not Intersect(theCell, ActiveSheet.Range("C1:C3")) Is *
Nothing) Then
* * * * * * * * ActiveSheet.Range("E1") = ActiveSheet..Range("E1") + theCell
* * * * * * End If
* * * * Next theCell
* * Next i
'
End Sub


"terilad" wrote:


Hi Eric,


This is doing the trick, what do I need to do to add more cells.


e.g. I have A1:A3 to total in D1 I want to add C1:C3 to total in cell E1,
how will this be added to the code.


Many thanks


Mark


"EricG" wrote:


You would need to add something like the following code to the module of the
worksheet you are working in. *It will add whatever you type into A1:A3 to D1.


HTH,


Eric


*****
Paste the code below into the worksheet's code module:
*****
Option Explicit


Private Sub Worksheet_Change(ByVal Target As Range)
* * Dim i As Long, j As Long
* * Dim nAreas As Long
* * Dim theCell As Range
'
* * nAreas = Target.Areas.Count
'
' Since "Target" can have multiple areas selected, we
' need to check each cell in each area to see if it is
' in the range "A1:A3".
'
* * For i = 1 To nAreas
* * * * For Each theCell In Target.Areas(i).Cells
* * * * * * If (Not Intersect(theCell, ActiveSheet.Range("A1:A3")) Is
Nothing) Then
* * * * * * * * ActiveSheet.Range("D1") = ActiveSheet.Range("D1") + theCell
* * * * * * End If
* * * * Next theCell
* * Next i
'
End Sub


"terilad" wrote:


Hello,


I have a range of cells for input of hours 8 or 12, these total up in a cell
D1, is there a way of keeping this rolling total in this cell when I delete
the hours I input, so if I input hours 12 into A1, A2, A3 the total in cell
D1 should be 36, when I delete the hours in cells A1, A2 and A3 I want the 36
still to remain in cell D1 and again start totalling when I add further hours
to cell A1, A2, A3 and so on so it stays as a rolling total all the time.


Any help would be much appreciated.


Many thanks


Mark


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Rolling 12 month total MH Excel Worksheet Functions 7 June 29th 09 06:52 PM
Rolling running total by date AOU Excel Discussion (Misc queries) 7 May 30th 07 12:44 AM
sum of rolling (set number cells above the total)l Ohmer4j Excel Discussion (Misc queries) 4 March 30th 07 09:48 PM
12 month Rolling Total Need Help Excel Worksheet Functions 0 September 22nd 06 03:19 PM
Sum Data in Col B, Add % of Total Col C, Add Rolling % of Total Co SteveC Excel Programming 2 January 26th 06 12:48 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"