Thread: Count?
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Steve Yandl Steve Yandl is offline
external usenet poster
 
Posts: 284
Default Count?

Here is one option.

For the example, I'm looking for how many times the value in cell C5
changes. The count appears in cell G2 and I've used cell G1 to store the
last changed value from C5 so there is a reference for comparison, if and
when the value of C5 is changed. The code goes in the worksheet, not a
module.

'_________________________________________________ _

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False

If Not Intersect(Target, Me.Range("C5")) Is Nothing Then
If Not Target.Value = Me.Range("G1").Value Then
Me.Range("G2").Value = Me.Range("G2").Value + 1
Me.Range("G1").Value = Target.Value
End If
End If

Application.EnableEvents = True

End Sub

__________________________________________________

Steve
"Mark J" wrote in message
...
I would like to know if I there is a way to count the number of times a
value
in a cell changes. I have a spreadsheet that reads in data from a "PLC"
and
the data changes throughout the day, what I am looking for is a way to
count
the times that "value" in the cell changed. Thanks