Originally Posted by
TMS
Put TargetUpdate in a standard module, or try Call Sheet1.TargetUpdate. I'd go with the first option. And you need to pass the Target range to the called subroutines.
I changed it to this: Still getting an error Argument not optional.
Sub Update()
Application.OnTime Now + TimeValue("00:02:00"), "my_macro"
End Sub
Sub my_macro()
For Each objconnection In ThisWorkbook.Connections
ThisWorkbook.RefreshAll
Next
Call Sheet1.TargetUpdate
Call Update
End Sub
Public Sub TargetUpdate(ByVal Target As Range)
On Error Resume Next
If Target.Cells.Count > 1 Then Exit Sub
Set xRg = Intersect(Range("F2"), Target)
If xRg Is Nothing Then Exit Sub
If IsNumeric(Target.Value) And Target.Value > Range("E2").Value Then
Call Mail_small_Text_Outlook
End If
End Sub
Sub Mail_small_Text_Outlook()
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = "" & vbNewLine & vbNewLine & _
"" & vbNewLine & _
""
On Error Resume Next
With xOutMail
.To = "[email protected]"
.CC = ""
.BCC = ""
.Subject = Range("F2").Value & " / " & Range("A2").Value
.Body = xMailBody
.Display 'or use .Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
Bookmarks