Counting a cell as it transitions from a "1" to a

stehaas

New Member
Joined
May 15, 2007
Messages
3
I am looking to tally a count (in Excel) as a cell transitions from a "0" to a "1"
As cell "A-1" transitions from a "0" to a "1" while recieving the signal from a external DDE device. I would like cell "B-1" to count up every time it sees a "1" while getting its transition signal.
Example
"0" to "1" = 1
"0" to "1" = 2
"0" to "1" = 3
"0" to "1" = 4
"0" to "1" = 5
 

Some videos you may like

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Joined
Jul 30, 2006
Messages
3,656
stehaas,

Try this:

Press and hold down the 'ALT' key, and press the 'F11' key.

Copy the below code, and paste it into VBAProject, Microsoft Excel Objects, Sheet1(Sheet1): or the sheetname where you want the counter to update.


Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub
    Application.ScreenUpdating = False
    If Target.Value = 1 Then
        Cells(1, 2) = Cells(1, 2) + 1
    End If
    Application.ScreenUpdating = True
End Sub

Each time cell A1 changes to a 1, the value in cell B1 will be updated by 1.

Have a great day,
Stan
 

zzjasonzz

Well-known Member
Joined
Apr 23, 2006
Messages
649
Stan, although i have no idea how to do it that will not work 100% as if the cell was anything other than a 1 before it will count.

Example
"0" to "1" = 1
"1" to "2" = 1
"2" to "1" = 2
 

stehaas

New Member
Joined
May 15, 2007
Messages
3
incremental count

Stan,
Thank you for your reply...I will give this a try,
stehaas
 

Watch MrExcel Video

Forum statistics

Threads
1,122,804
Messages
5,598,168
Members
414,215
Latest member
SRGDZMCS

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top