Hallöchen,
vielleicht kann mir jemand helfen... ;-) Ich habe ein Makro, das prüft, ob eine Zelle vom Wert Closed auf Ongoing oder Open gesetzt wurde. Wenn bereits Closed in der Zelle eingetragen wurde UND auf Open oder Ongoing zurückgesetzt wird, gibt es eine warnmeldung per MsgBox.
Jetzt soll genau bei diesem Ereignis eine Mail versendet werden. Allerdings wird bei meinem Makro immer eine Mail versendet, wenn der Zellwert geändert wird (egal ob closed, open oder ongoing). Weiß jemand, was ich im Makro falsch mache.... ;-) Vielen Dank vorab!
Private Sub Worksheet_Change(ByVal Target As Range)
Dim objOutlook As Object
Dim iclick As Integer
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 " & "from CLOSED to " & Target.Value & "! This can affect the whole xxx Group Closing Process!" _
& vbCrLf & vbCrLf & "JGM Group Accounting will be informed automatically by e-mail now." & vbCrLf & vbCrLf & "Please contact Ms. xxxx or Mr. xxxx", vbOKOnly, "!!Critical change during closing process!!"
With objMail
.To = "xxxx@xxx.de"
.Subject = "!!Financial closing alert!!"
.Body = "Financial closing alert " & Target.Address & Target.Value & " 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
|