View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
John Bundy John Bundy is offline
external usenet poster
 
Posts: 772
Default Accumulator Logic

Looks like bad code to me :)
the next should be an end if
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Address(False, False) = "D1" Then
If IsNumeric(.Value) Then
Application.EnableEvents = False
Range("c1").Value = Range("c1").Value + .Value
Application.EnableEvents = True
End If
End If
End With
End Sub

i wouldn't know why enableevents would matter unless there is more code
somewhere.
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"peyman" wrote:

hi,
I'm using the following code taken from "McGimpsey & Associates" site and it
works nicely for me but I'm not able to undrestand how the code works and
what its logic is.can anybody explain to more about this codes,particulary
the line "Application.EnableEvents = False or true"?thanx.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Address(False, False) = "D1" Then
If IsNumeric(.Value) Then
Application.EnableEvents = False
Range("c1").Value = Range("c1").Value + .Value
Application.EnableEvents = True
End If
Next
End With
End Sub