Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1720to1724
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

E-Mail versenden

E-Mail versenden
29.10.2019 08:47:41
Thomas
Guten Morgen liebe Excel-Liebhaber,
folgendes Problem:
in meinem Code wird eine E-Mail erstellt, sobald entsprechende Zelle in der die Spalte D geändert wird.
Beispiel:
Zelle D3 ist leer und wird mit einem x versehen. Dann wird durch das x eine E-Mail erstellt. ABER ich bekomme es nicht hin das die E-Mailadresse eingetragen wird die in Zell B3 steht.
Wenn D16 aktiviert wird soll die E-Mail Adresse von B16 genommen werden usw.
Also egal welche Zelle in D beschrieben wird es steht im die entsprechende Adresse in Spalte B
Hoffe ihr könnt mir helfen.
Danke euch schonmal im voraus.
Gruß Thomas

Private Sub Worksheet_Change(ByVal Target As Range)
'Updated by Extendoffice 2017/9/12
Dim xRgSel As Range
Dim xOutApp As Object
Dim xMailItem As Object
Dim xMailBody As String
On Error Resume Next
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set xRg = Range("D:D")
Set xRgSel = Intersect(Target, xRg)
ActiveWorkbook.Save
If Not xRgSel Is Nothing Then
Set xOutApp = CreateObject("Outlook.Application")
Set xMailItem = xOutApp.CreateItem(0)
xMailBody = "Hallo " & xRgSel.Address(False, False) & _
" in the worksheet '" & Me.Name & "' were modified on " & _
Format$(Now, "dd/mm/yyyy") & " at " & Format$(Now, "hh:mm:ss") & _
" by " & Environ$("username") & "."
With xMailItem
.To = "E-Mail Adresse"
.Subject = "APX von BMW bereitgestellt"
.Body = xMailBody
.Display
End With
Set xRgSel = Nothing
Set xOutApp = Nothing
Set xMailItem = Nothing
End If
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

6
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: E-Mail versenden
29.10.2019 08:58:31
Bernd
Servus Thomas,
teste mal:

.To = Activesheet.Cells(Target.Row,2).Value
Grüße, Bernd
AW: E-Mail versenden
29.10.2019 09:00:29
Werner
Hallo Thomas,
oder mit offset und deine xRgSel brauchst du nicht.
Private Sub Worksheet_Change(ByVal Target As Range)
'Updated by Extendoffice 2017/9/12
Dim xOutApp As Object, xMailItem As Object, xMailBody As String
On Error Resume Next
Application.ScreenUpdating = False
Application.DisplayAlerts = False
ActiveWorkbook.Save
If Not Intersect(Range("D:D"), Target) Is Nothing Then
Set xOutApp = CreateObject("Outlook.Application")
Set xMailItem = xOutApp.CreateItem(0)
xMailBody = "Hallo " & xRgSel.Address(False, False) & _
" in the worksheet '" & Me.Name & "' were modified on " & _
Format$(Now, "dd/mm/yyyy") & " at " & Format$(Now, "hh:mm:ss") & _
" by " & Environ$("username") & "."
With xMailItem
.To = Target.Offset(, -2)
.Subject = "APX von BMW bereitgestellt"
.Body = xMailBody
.Display
End With
Set xRgSel = Nothing
Set xOutApp = Nothing
Set xMailItem = Nothing
End If
Application.DisplayAlerts = True
End Sub
Gruß Werner
Anzeige
AW: E-Mail versenden
29.10.2019 09:05:55
Thomas
Hallo Zusammen,
super danke euch.
Gruß Thomas
noch mal..
29.10.2019 09:05:26
Werner
Hallo Thomas,
..hab gerade gesehen, dass du die xRgSel im Code noch mal verwendet hast.
Private Sub Worksheet_Change(ByVal Target As Range)
'Updated by Extendoffice 2017/9/12
Dim xOutApp As Object, xMailItem As Object, xMailBody As String
On Error Resume Next
Application.ScreenUpdating = False
Application.DisplayAlerts = False
ActiveWorkbook.Save
If Not Intersect(Range("D:D"), Target) Is Nothing Then
Set xOutApp = CreateObject("Outlook.Application")
Set xMailItem = xOutApp.CreateItem(0)
xMailBody = "Hallo " & Target.Address(0, 0) & _
" in the worksheet '" & Me.Name & "' were modified on " & _
Format$(Now, "dd/mm/yyyy") & " at " & Format$(Now, "hh:mm:ss") & _
" by " & Environ$("username") & "."
With xMailItem
.To = Target.Offset(, -2)
.Subject = "APX von BMW bereitgestellt"
.Body = xMailBody
.Display
End With
End If
Set xOutApp = Nothing: Set xMailItem = Nothing
Application.DisplayAlerts = True
End Sub
Gruß Werner
Anzeige
AW: Danke
29.10.2019 09:17:49
Thomas
Danke
Gerne u. Danke für die Rückmeldung. o.w.T.
29.10.2019 09:42:25
Werner

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige