У меня есть некоторый код, настроенный для создания встречи в Outlook, хотя я пытаюсь установить начало за 30 дней до даты, указанной в ячейке столбца G (i, 7)
Есть ли способ сделать это, или мне нужно просто добавить дополнительный столбец в Excel с этой датой в?
Option Explicit
Option Compare Text 'ignore case sensitivity when comparing strings
Sub EventsReminders()
Dim OL As Outlook.Application, ES As Worksheet, _
r As Long, i As Long, wb As ThisWorkbook
Set wb = ThisWorkbook
Set ES = wb.Sheets("Events")
Set OL = New Outlook.Application
r = ES.Cells(Rows.Count, 1).End(xlUp).Row
For i = 8 To r
With ES.Cells(i, 2)
If .Value = "Yes" And ES.Cells(i, 3) <> "Yes" Then
ES.Cells(i, 3) = "Yes"
With OL.CreateItem(olAppointmentItem)
.Subject = "Raise works order"
.Start = ES.Cells(i, 7) + TimeValue("09:00:00")
.ReminderSet = True
.ReminderMinutesBeforeStart = 60
.Body = ES.Cells(i, 5).Value + "_" + ES.Cells(i, 9).Value
.Save
End With
End If
End With
Next i
Set OL = Nothing
Set wb = Nothing
Set ES = Nothing
End Sub