Please help me get this accumulator working

B

Bill Craig

I've read everything in this group about how to get an accumulator
going. Here's my task:

DailyClosingEntry > SummaryClosingEntry
Cash > Cash
Credit > Credit
Etc. > Etc.

Here's the code I'm trying:

(in the DailyClosingEntry Worksheet module)

Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If .Address(False, False, , False) = _
Worksheets("DailyClosingEntry").Range("C5") Then
If IsNumeric(.Value) Then
Application.EnableEvents = False

Worksheets("SummaryClosingEntry").Range("C5").Value= _

Worksheets("DailyClosingEntry").Range("C5").Value+.Value
Application.EnableEvents = True
End If
End If
End With

End Sub

Result: Nothing in the SummaryClosingEntry cell. What am I doing
wrong?

Thanks in Advance.
 
F

Frank Kabel

Hi
try the following code (see:
http://www.mcgimpsey.com/excel/accumulator.html):
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Static accumulator As Double
With Target
If .Address(False, False) = "C5" Then
If Not IsEmpty(.Value) And IsNumeric(.Value) Then
accumulator = accumulator + .Value
Else
accumulator = 0
End If
Application.EnableEvents = False
.Value = accumulator
Application.EnableEvents = True
End If
End With
End Sub
 
Top