View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
bahri bahri is offline
external usenet poster
 
Posts: 8
Default Impossible with formula BUT

Hi!
That works Great
Thanks

Regs
bahri
"Dave Peterson" wrote in message
...
So you're putting the accumulator in column B (not in the row below),
right?

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Excel.Range)

If Target.Cells.Count 1 Then
Exit Sub 'one cell at a time!
End If

'change the range to check here
If Intersect(Target, Me.Range("A1:A10")) Is Nothing Then
Exit Sub
End If

With Target
If IsNumeric(.Value) Then
If IsNumeric(.Offset(0, 1).Value) Then
Application.EnableEvents = False
.Offset(0, 1).Value = .Offset(0, 1).Value + .Value
Application.EnableEvents = True
End If
End If
End With
End Sub

bahri wrote:

Hi
I have tried a few things out.
Works great on one instance that is applied to one row and combining for
two
rows as below for rows 1 and 2:
==================
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Address(False, False) = "A1" Then
If IsNumeric(.Value) Then
Application.EnableEvents = False
Range("B1").Value = Range("B1").Value + .Value
Application.EnableEvents = True
End If
End If
End With

With Target
If .Address(False, False) = "A2" Then
If IsNumeric(.Value) Then
Application.EnableEvents = False
Range("B2").Value = Range("B2").Value + .Value
Application.EnableEvents = True
End If
End If
End With
End Sub
=====================
However is there a way to apply the macro for several rows without
producing
such long code?
Thanks all

Regards
bahri


--

Dave Peterson