Hello,
My worksheet is getting live data from DDE to excel.
I need macro to run only when the value in T and U columns are = 1
I have a piece of code witch is working.
Problem is that it is flickering constantly.
What i have tried:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
It only works when i insert value anywhere on the sheet..
I need it to run automatically, when the value in T changes to = 1, from False..
Looking for solution to this, thank you.
Option Explicit
Sub Worksheet_Calculate()
Dim FormulaRange As Range
Dim NotSentMsg As String
Dim MyMsg As String
Dim SentMsg As String
Dim SentMsg2 As String
Dim MyLimit As Double
NotSentMsg = ""
SentMsg = "Alert"
SentMsg2 = "e-Mail sent"
'Above the MyLimit value it will run the macro
MyLimit = 0
'Set the range with the Formula that i want to check
Set FormulaRange = Me.Range("T4:T31")
'MsgBox "Cell " & .Address & " has changed."
'On Error GoTo EndMacro:
For Each FormulaCell In FormulaRange.Cells
With FormulaCell
If .Offset(0, 4).Value <> SentMsg2 Then
If IsNumeric(.Value) = False Then
MyMsg = ""
Else
If .Value > MyLimit Then
MyMsg = SentMsg
'MsgBox "11111"
If .Offset(0, 2).Value = NotSentMsg Then
Call Mail_with_outlook_BuyMsg
End If
Else
MyMsg = NotSentMsg
End If
End If
Application.EnableEvents = False
.Offset(0, 2).Value = MyMsg 'inserted "Alert" message
'MsgBox "01 BUY nothing"
Application.EnableEvents = True
If .Offset(0, 2).Value = SentMsg Then
.Offset(0, 4).Value = SentMsg2 'inserted "e-Mail sent" message
End If
End If
End With
Next FormulaCell
'ExitMacro:
Call Worksheet_Calculate2
'EndMacro:
'Application.EnableEvents = True
'MsgBox "Some Error occurred."
'& vbLf & Err.Number _
'& vbLf & Err.Description
'Application.ScreenUpdating = True
End Sub
Macro for U Column is the same as for T.