Intergrate a cell

T

Tom

I have a pulse (either a "1" or "0") that inputs to a
single cell. Over a period of time (30 days) I need to
count the number of "1" that occurred at that one cell.
The input cell will either have a "1" or a "0" at any time,
no other inputs.
Thanks Tw
 
D

Don Guillett

This works for the SAME cell. To start over use 0

Option Explicit

Dim oldvalue As Double
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$A$5" Then
Application.EnableEvents = False
If Target.Value = 0 Then oldvalue = 0
Target.Value = 1 * Target.Value + oldvalue
oldvalue = Target.Value
Application.EnableEvents = True
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top