Hi,
i have two cells bid q sum (E87) and ask q sum (E88), these values continuously update via means of an API for my trading software.
what im trying to achieve is whenever E87/88 update, i want their previous values stored in F87/88 respectively,
Im a novice with vba and so far have this, which doesnt appear to work:
Private Sub Worksheet_Calculate()
Static oldValueD87 As Variant
' Check if the value of D87 has changed
If Me.Range("D87").Value <> oldValueD87 Then
Application.EnableEvents = False ' Disable events to prevent recursive calls
On Error GoTo CleanUp
' Store the old value of D87 in E87
If Not IsEmpty(oldValueD87) Then
Me.Range("E87").Value = oldValueD87
End If
' Update oldValueD87 with the new value of D87
oldValueD87 = Me.Range("D87").Value
CleanUp:
Application.EnableEvents = True ' Re-enable events
If Err.Number <> 0 Then Err.Clear ' Clear errors if any
End If
End Sub
any help appreciated
Luke