Ich möchte um Hilfe bitten, wie ich Ron de Bruins Code von Spalte zu Zeile ändern kann (zB Zeile 1 enthält Name; Zeile 2 E-Mail; Zeile 3 entspricht entweder ja oder Nein).Eine Nachricht an jede Person in einem Bereich senden (Zeile)
Sub Test1()
'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
'Working in Office 2000-2016
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "?*@?*.?*" And _
LCase(Cells(cell.Row, "C").Value) = "yes" Then
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = cell.Value
.Subject = "Reminder"
.Body = "Dear " & Cells(cell.Row, "A").Value _
& vbNewLine & vbNewLine & _
"Please contact us to discuss bringing " & _
"your account up to date"
'You can add files also like this
'.Attachments.Add ("C:\test.txt")
.Send 'Or use Display
End With
On Error GoTo 0
Set OutMail = Nothing
End If
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub
Vielen Dank im Voraus!
Danke für Ihre Antwort! Angenommen, Zeile 18 (H18: AE18) enthält die E-Mail-Adresse (abgeleitet von Zeile 19 {Name} & "@ yahoo.com") und das "Ja" oder Leerzeichen in Zeile 20, gilt dies immer noch, wenn ich die Spalte geändert habe ("B") zu "H"? –
Der Code durchläuft die Gruppe von Zellen in SpecialCells (xlCellTypeConstants) .Areas in nur einer Spalte. Also wird es auch für die Spalte H funktionieren, wenn die Daten die Kriterien erfüllen, die ich unter dem Code erwähnt habe. – sktneer