excel 2016 Here is my vba code
Sub datesexcelvba()
Dim myapp As Outlook.Application, mymial As Outlook.MailItem
Dim mydate1 As Date
Dim mydate2 As Long
Dim datetoday1 As Date
Dim datetoday2 As Long
Dim x As Long
lastrow = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
For x = 2 To lastrow
mydate1 = Cells(x, 6).Value
maydate2 = mydate1
Cells(x, 9).Value = mydate1
datetoday1 = Date
datetoday2 = datetoday1
mydate2 = mydate1
Cells(x, 10).Value = datetoday2
If mydate2 - datetoday2 = 3 Then
Set myapp = New Outlook.Application
Set mymail = myapp.CreateItem(olMailItem)
mymail.To = Cells(x, 5).Value
With mymail
.Subject = "Submittal Reminder"
.Body = "Hello I hope your day is off to a good start." & vbCrLf & "Submittals are due in three days please forward submittals as outlined to Storm Industrial Investments LLC Texas Project Team Thak you." & vbCrLf & "Kindly disregard if already submitted." & vbCrLf & "john smith"
.Display
'.send
End With
Cells(x, 7) = "Yes"
Cells(x, 7).Interior.ColorIndex = 6
Cells(x, 7).Font.ColorIndex = 3
Cells(x, 7).Font.Bold = True
Cells(x, 8).Value = mydate2 - datetoday2
End If
Next
Set myapp = Nothing
Set mymail = Nothing
End Sub
This code starts in row 2 but does not want to work beyond row 6 I can not figure out why, when it should look for last row? Also is there a fix, add/change code to have outlook insert my email signature, I believe this would be in the of code that starts with .body?
I also notice that it does not sent the email automatically, the code only open up the email(s) one would have to click on each email send button to send it, again what can we fix,add and/or change in the code to send automatically.
[TABLE="width: 1327"]
<tbody>[TR]
[TD]no.[/TD]
[TD]name[/TD]
[TD]last[/TD]
[TD]contact[/TD]
[TD]email address[/TD]
[TD]date of payment mydate1 column 6 (x,6)[/TD]
[TD]reminders column 7 (x,7)[/TD]
[TD]days diffeerence column 8 (x,8)[/TD]
[TD]date numbers mydate2 column 9 (x,9) datetoday 1 = date numbers[/TD]
[TD]today as numbers / todays date column 10 (x,10) datetoday2 = system date[/TD]
[TD="align: left"]
<tbody>
</tbody>[/TD]
[/TR]
[TR]
[TD]mr[/TD]
[TD]john[/TD]
[TD]smith[/TD]
[TD][/TD]
[TD]email address[/TD]
[TD="align: right"]11/30/17[/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]11/30/2017[/TD]
[TD="align: right"]43069[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]mr[/TD]
[TD]john [/TD]
[TD]smith[/TD]
[TD][/TD]
[TD]email address[/TD]
[TD="align: right"]12/21/17[/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]12/21/2017[/TD]
[TD="align: right"]43069[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]mr[/TD]
[TD]john[/TD]
[TD]smith[/TD]
[TD][/TD]
[TD]email address[/TD]
[TD="align: right"]12/03/17[/TD]
[TD]Yes[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]12/3/2017[/TD]
[TD="align: right"]43069[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]mr[/TD]
[TD]john[/TD]
[TD]smith[/TD]
[TD][/TD]
[TD]email address[/TD]
[TD="align: right"]12/14/17[/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]12/14/2017[/TD]
[TD="align: right"]43069[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]mr[/TD]
[TD]john[/TD]
[TD]smith[/TD]
[TD][/TD]
[TD]email address[/TD]
[TD="align: right"]12/03/17[/TD]
[TD]Yes[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]12/3/2017[/TD]
[TD="align: right"]43069[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Sub datesexcelvba()
Dim myapp As Outlook.Application, mymial As Outlook.MailItem
Dim mydate1 As Date
Dim mydate2 As Long
Dim datetoday1 As Date
Dim datetoday2 As Long
Dim x As Long
lastrow = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
For x = 2 To lastrow
mydate1 = Cells(x, 6).Value
maydate2 = mydate1
Cells(x, 9).Value = mydate1
datetoday1 = Date
datetoday2 = datetoday1
mydate2 = mydate1
Cells(x, 10).Value = datetoday2
If mydate2 - datetoday2 = 3 Then
Set myapp = New Outlook.Application
Set mymail = myapp.CreateItem(olMailItem)
mymail.To = Cells(x, 5).Value
With mymail
.Subject = "Submittal Reminder"
.Body = "Hello I hope your day is off to a good start." & vbCrLf & "Submittals are due in three days please forward submittals as outlined to Storm Industrial Investments LLC Texas Project Team Thak you." & vbCrLf & "Kindly disregard if already submitted." & vbCrLf & "john smith"
.Display
'.send
End With
Cells(x, 7) = "Yes"
Cells(x, 7).Interior.ColorIndex = 6
Cells(x, 7).Font.ColorIndex = 3
Cells(x, 7).Font.Bold = True
Cells(x, 8).Value = mydate2 - datetoday2
End If
Next
Set myapp = Nothing
Set mymail = Nothing
End Sub
This code starts in row 2 but does not want to work beyond row 6 I can not figure out why, when it should look for last row? Also is there a fix, add/change code to have outlook insert my email signature, I believe this would be in the of code that starts with .body?
I also notice that it does not sent the email automatically, the code only open up the email(s) one would have to click on each email send button to send it, again what can we fix,add and/or change in the code to send automatically.
[TABLE="width: 1327"]
<tbody>[TR]
[TD]no.[/TD]
[TD]name[/TD]
[TD]last[/TD]
[TD]contact[/TD]
[TD]email address[/TD]
[TD]date of payment mydate1 column 6 (x,6)[/TD]
[TD]reminders column 7 (x,7)[/TD]
[TD]days diffeerence column 8 (x,8)[/TD]
[TD]date numbers mydate2 column 9 (x,9) datetoday 1 = date numbers[/TD]
[TD]today as numbers / todays date column 10 (x,10) datetoday2 = system date[/TD]
[TD="align: left"]
<tbody>
</tbody>
[/TR]
[TR]
[TD]mr[/TD]
[TD]john[/TD]
[TD]smith[/TD]
[TD][/TD]
[TD]email address[/TD]
[TD="align: right"]11/30/17[/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]11/30/2017[/TD]
[TD="align: right"]43069[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]mr[/TD]
[TD]john [/TD]
[TD]smith[/TD]
[TD][/TD]
[TD]email address[/TD]
[TD="align: right"]12/21/17[/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]12/21/2017[/TD]
[TD="align: right"]43069[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]mr[/TD]
[TD]john[/TD]
[TD]smith[/TD]
[TD][/TD]
[TD]email address[/TD]
[TD="align: right"]12/03/17[/TD]
[TD]Yes[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]12/3/2017[/TD]
[TD="align: right"]43069[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]mr[/TD]
[TD]john[/TD]
[TD]smith[/TD]
[TD][/TD]
[TD]email address[/TD]
[TD="align: right"]12/14/17[/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]12/14/2017[/TD]
[TD="align: right"]43069[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]mr[/TD]
[TD]john[/TD]
[TD]smith[/TD]
[TD][/TD]
[TD]email address[/TD]
[TD="align: right"]12/03/17[/TD]
[TD]Yes[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]12/3/2017[/TD]
[TD="align: right"]43069[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Last edited: