Hey guys,
I have a macro that executes when a specific cell changes based on the data incoming from an RTD link. The code I below have almost works but instead of triggering the macro when cell F2 in sheet "15 Mins Bars" changes, it triggers when any cell in the entire workbook changes. Not sure how to specify this in the Dim and Set part of the code as I'm unfamiliar with that section.
I have a macro that executes when a specific cell changes based on the data incoming from an RTD link. The code I below have almost works but instead of triggering the macro when cell F2 in sheet "15 Mins Bars" changes, it triggers when any cell in the entire workbook changes. Not sure how to specify this in the Dim and Set part of the code as I'm unfamiliar with that section.
VBA Code:
Public Prev_Val As Long
Private Sub Worksheet_Calculate()
Dim rngF3 As Range
Set rngF3 = Range("F2")
If rngF3 <> Prev_Val Then
Application.EnableEvents = False
Application.ScreenUpdating = False
With Sheets("15 Min Bars").Rows("4:4")
.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End With
With Sheets("15 Min Bars").Range("B2:E2")
.Copy
End With
With Sheets("15 Min Bars").Range("A4")
.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End With
Application.CutCopyMode = False
Application.ScreenUpdating = True
Application.EnableEvents = True
End If
End Sub