View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Count the number of changes to a cell

Works for me.

Enter 0 in C1 and add something to A1

Change A1 and number in C1 increases for me each time a change is made.

Thanks for pointing out the not turning avents back on. Damn copy and paste<g


Gord

On Fri, 5 Oct 2007 02:45:25 -0400, "T. Valko" wrote:

Gord, I couldn't get this to work properly.

It only counted a change once. The counter cell went from 0 to 1 and that's
it!

You left events disabled at the end. Even turning events back on didn't make
a difference.

--
Biff
Microsoft Excel MVP


"Gord Dibben" <gorddibbATshawDOTca wrote in message
.. .
Event code can do this.

Enter a 0 in C1 then copy/paste this code into your worksheet module.

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Me.Range("A1")) Is Nothing Then Exit Sub
On Error GoTo enditall
Application.EnableEvents = False
If Target.Value < "" Then
With Target.Offset(0, 2)
.Value = .Value + 1
End With
End If
enditall:
Application.EnableEvents = False
End Sub