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
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,215,045
Messages
6,122,840
Members
449,096
Latest member
Erald

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
Back
Top