Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need help adding accumulator cells


Hello, I have entered the code below and it works just great but my
problem is that at the end I add up the two accumulator cells but it
only works for one row how do I get it to work for all the rows? Thanks
in advance for any help given.

Dawn

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Target.Column = 3 Then
Target(1, 5).Value = Target(1, 5).Value + Target.Value
End If
If Target.Cells.Count 1 Then Exit Sub
If Target.Column = 4 Then
Target(1, 5).Value = Target(1, 5).Value + Target.Value
End If
If Target.Cells.Count 1 Then Exit Sub
If Target.Column = 5 Then
Target(1, 5).Value = Target(1, 5).Value + Target.Value
End If
If Target.Cells.Count 1 Then Exit Sub
If Target.Column = 12 Then
Target(1, 5).Value = Target(1, 5).Value + Target.Value
End If
If Target.Cells.Count 1 Then Exit Sub
If Target.Column = 13 Then
Target(1, 5).Value = Target(1, 5).Value + Target.Value
End If
If Target.Cells.Count 1 Then Exit Sub
If Target.Column = 14 Then
Target(1, 5).Value = Target(1, 5).Value + Target.Value
End If
Dim x As Single
x = Range("G13").Value
Range("U13").Value = x + Range("P13").Value
End Sub


--
dlashley
------------------------------------------------------------------------
dlashley's Profile: http://www.excelforum.com/member.php...o&userid=34369
View this thread: http://www.excelforum.com/showthread...hreadid=541619

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Need help adding accumulator cells

One way:

Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If .Cells.Count 1 Then Exit Sub
On Error GoTo ErrHandler
Application.EnableEvents = False
If Not Intersect(.Cells, Range("C:E,L:N")) Is Nothing Then _
.Offset(0, 4).Value = .Offset(0, 4).Value + .Value
Cells(.Row, "U").Value = Cells(.Row, "G").Value + _
Cells(.Row, "P").Value
End With
ErrHandler:
Application.EnableEvents = True
On Error GoTo 0
End Sub




In article ,
dlashley
wrote:

Hello, I have entered the code below and it works just great but my
problem is that at the end I add up the two accumulator cells but it
only works for one row how do I get it to work for all the rows? Thanks
in advance for any help given.

Dawn

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Target.Column = 3 Then
Target(1, 5).Value = Target(1, 5).Value + Target.Value
End If
If Target.Cells.Count 1 Then Exit Sub
If Target.Column = 4 Then
Target(1, 5).Value = Target(1, 5).Value + Target.Value
End If
If Target.Cells.Count 1 Then Exit Sub
If Target.Column = 5 Then
Target(1, 5).Value = Target(1, 5).Value + Target.Value
End If
If Target.Cells.Count 1 Then Exit Sub
If Target.Column = 12 Then
Target(1, 5).Value = Target(1, 5).Value + Target.Value
End If
If Target.Cells.Count 1 Then Exit Sub
If Target.Column = 13 Then
Target(1, 5).Value = Target(1, 5).Value + Target.Value
End If
If Target.Cells.Count 1 Then Exit Sub
If Target.Column = 14 Then
Target(1, 5).Value = Target(1, 5).Value + Target.Value
End If
Dim x As Single
x = Range("G13").Value
Range("U13").Value = x + Range("P13").Value
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need help adding accumulator cells


Thank for your response but now I am confused do I add this to m
current code or add a new one

--
dlashle
-----------------------------------------------------------------------
dlashley's Profile: http://www.excelforum.com/member.php...fo&userid=3436
View this thread: http://www.excelforum.com/showthread.php?threadid=54161

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Need help adding accumulator cells

You can only have one Worksheet_Change() macro per worksheet. Replace
your current code with the code I posted.

In article ,
dlashley wrote:

Thank for your response but now I am confused do I add this to my
current code or add a new one?

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
Accumulator BadBoy Excel Worksheet Functions 2 April 24th 09 12:25 PM
accumulator with other than one dan Excel Worksheet Functions 8 November 24th 06 06:29 PM
Accumulator cells Tom Excel Programming 3 May 12th 06 10:22 PM
Adding an accumulator for multiple cells jrambo63 Excel Worksheet Functions 3 May 26th 05 05:50 PM
Please help fix my accumulator Tim McMahon Excel Programming 3 May 23rd 04 09:06 PM


All times are GMT +1. The time now is 12:30 PM.

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

About Us

"It's about Microsoft Excel"