excelvbaexcel-formuladde

Excel live data counter (DDE Server)


I'm using DDE server to import live data on excel on two columns, the data changes every second.

What im currently doing is i have live data on Cell A1 and live data on Cell B1 on Cell C1 i have the following formula

=A1=B1

Which is suppose to be true, but sometimes the result is false (as cell A1 doesn't match cell B1)

I want to calculate how many times "false" is the result in C1

My problem is its a live data and changes almost every second, and my result should be accumulated. Does anyone have any suggestion on how can it be done on excel?

Thanks,


Solution

  • Give this a try :

    Private Sub Worksheet_Calculate()
    
    Dim Count As Long
    Dim KeyCells As Range
    
    Set KeyCells = Range("C1")
    
    Count = 0
    
    If IsEmpty(Range("D1").Value) = False Then
        Count = Range("D1").Value
    End If
    
    
        If KeyCells.Value = False Then
            Count = Count + 1
            Range("D1").Value = Count
        End If
    
    End Sub
    

    Note : Here D1 Cells will Save the counted value, Change the cells if needed ... This code will count how much time "False" are returned ..

    Credit to tim for worksheet_calculate()