Gruppe
Extern
Problem
Wenn ein durch eine Formel ermittelter Zellwert einen Grenzwert übersteigt, soll eine Info-Mail mit Outlook versandt werden.
ClassModule: Tabelle1
Private Sub Worksheet_Calculate()
If Range("A1") > 100 Then Call SendMessage
End Sub
StandardModule: basMain
Sub SendMessage()
Dim oOL As Object
Dim oOLMsg As Object
Dim oOLRecip As Object
Set oOL = CreateObject("Outlook.Application")
Set oOLMsg = oOL.CreateItem(0)
With oOLMsg
Set oOLRecip = .Recipients.Add(Range("G1").Value)
.Subject = "Zellwert > 100"
.Body = "Zellwert: " & ActiveSheet.Range("A1")
.Importance = 0
.Send
End With
oOLRecip.Resolve
Set oOLMsg = Nothing
Set oOLRecip = Nothing
Set oOL = Nothing
End Sub