omerap06
Altın Üye
- Katılım
- 7 Mart 2024
- Mesajlar
- 35
- Excel Vers. ve Dili
- 2020
- Altın Üyelik Bitiş Tarihi
- 20-03-2025
Sub Düğme1_Tıkla()
Dim ws As Worksheet
Dim rngTarih As Range, cellTarih As Range
Dim acilAdres As String, acilDegilAdres As String
Dim mailKonu As String, mailIcerik As String
Dim outlookApp As Object
Dim outlookMail As Object
Dim sonSatir As Long
Set ws = ThisWorkbook.Sheets("LİSTE")
sonSatir = ws.Cells(ws.Rows.Count, "L").End(xlUp).Row
Set rngTarih = ws.Range("L7:L" & sonSatir)
mailKonu = "Tarihi Geçen Değerler"
mailIcerik = "Acil:" & vbCrLf
For Each cellTarih In rngTarih
If cellTarih.Value < Date - 10 And cellTarih.Value > Date - 30 Then
If acilAdres = "" Then
acilAdres = cellTarih.Row
Else
acilAdres = acilAdres & ", " & cellTarih.Row
End If
ElseIf cellTarih.Value <= Date + 10 And cellTarih.Value >= Date Then
If acilDegilAdres = "" Then
acilDegilAdres = cellTarih.Row
Else
acilDegilAdres = acilDegilAdres & ", " & cellTarih.Row
End If
End If
Next cellTarih
If acilAdres <> "" Then
mailIcerik = mailIcerik & "10 günden az kalanlar:" & vbCrLf
For Each rowNo In Split(acilAdres, ", ")
mailIcerik = mailIcerik & ws.Cells(rowNo, "L").Value & " - " & ws.Cells(rowNo, "B").Value & " - " & ws.Cells(rowNo, "F").Value & " - " & ws.Cells(rowNo, "G").Value & " - " & ws.Cells(rowNo, "H").Value & vbCrLf
Next rowNo
End If
If acilDegilAdres <> "" Then
mailIcerik = mailIcerik & vbCrLf & "Acil Değil:" & vbCrLf
For Each rowNo In Split(acilDegilAdres, ", ")
mailIcerik = mailIcerik & ws.Cells(rowNo, "L").Value & " - " & ws.Cells(rowNo, "B").Value & " - " & ws.Cells(rowNo, "F").Value & " - " & ws.Cells(rowNo, "G").Value & " - " & ws.Cells(rowNo, "H").Value & vbCrLf
Next rowNo
End If
Set outlookApp = CreateObject("Outlook.Application")
Set outlookMail = outlookApp.CreateItem(0)
With outlookMail
.To = "o.ankara19@hotmail.com"
.Subject = mailKonu
.Body = mailIcerik
.Send
End With
Set outlookMail = Nothing
Set outlookApp = Nothing
End Sub
Yapmak istediğim şu :listeden L sutunundaki tarihlere baksın 10 günden az olan var ise mailin konusunda "acil:" adı altında altına B F G H sutunundaki bilgiler yazsın ve yine 10 günden fazla ve 30 günden az olan tarihlere baksın "acil değil" adı altında B F G H sutunundaki bilgiler yazsın 30 günden fazla tarihi olanları ise hiç yazmasın isteğim bu dur kodu yazdım ama çıktısı attığım resimdeki gibi sadece 2 parça oluyor çözemedim yardım edebilecek bir üstadım var mı?
Dim ws As Worksheet
Dim rngTarih As Range, cellTarih As Range
Dim acilAdres As String, acilDegilAdres As String
Dim mailKonu As String, mailIcerik As String
Dim outlookApp As Object
Dim outlookMail As Object
Dim sonSatir As Long
Set ws = ThisWorkbook.Sheets("LİSTE")
sonSatir = ws.Cells(ws.Rows.Count, "L").End(xlUp).Row
Set rngTarih = ws.Range("L7:L" & sonSatir)
mailKonu = "Tarihi Geçen Değerler"
mailIcerik = "Acil:" & vbCrLf
For Each cellTarih In rngTarih
If cellTarih.Value < Date - 10 And cellTarih.Value > Date - 30 Then
If acilAdres = "" Then
acilAdres = cellTarih.Row
Else
acilAdres = acilAdres & ", " & cellTarih.Row
End If
ElseIf cellTarih.Value <= Date + 10 And cellTarih.Value >= Date Then
If acilDegilAdres = "" Then
acilDegilAdres = cellTarih.Row
Else
acilDegilAdres = acilDegilAdres & ", " & cellTarih.Row
End If
End If
Next cellTarih
If acilAdres <> "" Then
mailIcerik = mailIcerik & "10 günden az kalanlar:" & vbCrLf
For Each rowNo In Split(acilAdres, ", ")
mailIcerik = mailIcerik & ws.Cells(rowNo, "L").Value & " - " & ws.Cells(rowNo, "B").Value & " - " & ws.Cells(rowNo, "F").Value & " - " & ws.Cells(rowNo, "G").Value & " - " & ws.Cells(rowNo, "H").Value & vbCrLf
Next rowNo
End If
If acilDegilAdres <> "" Then
mailIcerik = mailIcerik & vbCrLf & "Acil Değil:" & vbCrLf
For Each rowNo In Split(acilDegilAdres, ", ")
mailIcerik = mailIcerik & ws.Cells(rowNo, "L").Value & " - " & ws.Cells(rowNo, "B").Value & " - " & ws.Cells(rowNo, "F").Value & " - " & ws.Cells(rowNo, "G").Value & " - " & ws.Cells(rowNo, "H").Value & vbCrLf
Next rowNo
End If
Set outlookApp = CreateObject("Outlook.Application")
Set outlookMail = outlookApp.CreateItem(0)
With outlookMail
.To = "o.ankara19@hotmail.com"
.Subject = mailKonu
.Body = mailIcerik
.Send
End With
Set outlookMail = Nothing
Set outlookApp = Nothing
End Sub
Yapmak istediğim şu :listeden L sutunundaki tarihlere baksın 10 günden az olan var ise mailin konusunda "acil:" adı altında altına B F G H sutunundaki bilgiler yazsın ve yine 10 günden fazla ve 30 günden az olan tarihlere baksın "acil değil" adı altında B F G H sutunundaki bilgiler yazsın 30 günden fazla tarihi olanları ise hiç yazmasın isteğim bu dur kodu yazdım ama çıktısı attığım resimdeki gibi sadece 2 parça oluyor çözemedim yardım edebilecek bir üstadım var mı?
Ekli dosyalar
-
368.5 KB Görüntüleme: 2
-
32.7 KB Görüntüleme: 2