Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1816to1820
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Mail bei MsgBox

Mail bei MsgBox
13.03.2021 14:49:10
Andy
Hallo zusammen,
Nepomuk hat mir hier schon super geholfen bei meinem Vorhaben. Besten Dank dafür!
Ich habe nun ein Makro, dass eine MsgBox ausgibt, wenn sich der Status einer Zelle in einem bestimmten Bereich vom ursprünglichen Wert "CLOSED" auf "OPEN" oder "ONGOING" ändert. Der User soll also nur auf Closed setzen, wenn wirklich erledigt. Setzt er den Status von Closed auf Open oder Ongoing zurück, kann das kritische Auswirkungen haben.
Nun habe ich noch eingebaut, dass automatisch eine Mail versendet wird, wenn das auftritt. Allerdings sendet die Mail leider immer, wenn sich der Status ändert. Es soll aber nur passieren, wenn die MsgBox aufgerufen wird - weil dann das kritische Ereignis stattfindet. Könnte mal jemand über das Makro schauen, was ich falsch mache? Vielen Dank!!!
Option Explicit
Private mobjCell As Range

Private Sub Worksheet_Change(ByVal Target As Range)
Dim objOutlook As Object
Dim objMail As Object
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
If Not Application.Intersect(Range("Q10:Q1000"), Range(Target.Address)) Is Nothing Then _
If Not mobjCell Is Nothing Then If Target.Value = "OPEN" Or Target.Value = "ONGOING"  _
Then _
MsgBox "You have been reset the status in Cell " & Target.Address & " from a formerly    _
_
_
_
CLOSED Status to OPEN or ONGOING." _
& vbCrLf & vbCrLf & "This can affect the whole xxxx Group Closing Process!" _
& vbCrLf & vbCrLf & "xxxx will be informed automatically by e-mail now. Please contact   _
_
_
_
xxxxx", vbCritical, "!!Critical change during closing process!!"
With objMail
.To = "xxxxx.de"
.Subject = "!!Financial closing alert!!"
.Body = "Financial closing alert " & Target.Address & "  has been reset from closed status"
.Send
End With
End Sub


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Range("Q10:Q1000"), Range(Target.Address)) Is Nothing Then
If Target.Cells(1, 1).Value = "CLOSED" Then
Set mobjCell = Target
Else
Set mobjCell = Nothing
End If
End If
End Sub


1
Beitrag zum Forumthread
Beitrag zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Mail bei MsgBox
15.03.2021 07:49:18
MRUTOR
Hallo Andy,
versuch mal:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim objOutlook As Object
Dim objMail As Object
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
If Not Application.Intersect(Range("Q10:Q1000"), Range(Target.Address)) Is Nothing Then
If Not mobjCell Is Nothing Then
If Target.Value = "OPEN" Or Target.Value = "ONGOING" Then
MsgBox "You have been reset the status in Cell " & Target.Address & " from a  _
formerly CLOSED Status to OPEN or ONGOING." & vbCrLf & vbCrLf & "This can affect the whole xxxx Group Closing Process!" & vbCrLf & vbCrLf & "xxxx will be informed automatically by e-mail now. Please contact xxxxx", vbCritical, "!!Critical change during closing process!!"
With objMail
.to = "xxxxx.de"
.Subject = "!!Financial closing alert!!"
.Body = "Financial closing alert " & Target.Address & "  has been reset  _
from closed status"
.Send
End With
Else
Exit Sub
End If
End If
End If
End Sub

Gruss Tor
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige