rafaelbatalha
New member
Hello and good day to all!
I have a problem that i can't solve.
I have a excel sheet that run's a macro every time a close it.
The macro (that i found online) creates an event in Outlook calendars of diferent recipients.
The problem is that every time i open the sheet and add a new event, the macro repeats the alreday created events when i just want it to add the newest event.
I am not a programer and don't know how to code so please be patiente
I have this VBA code and it works for me but i don't know how to add the conditional format to make the macro run only on the most recent events.
can anyone please help??? here is the code
VBA Code:
Option Explicit
Sub AddAppointments()
Dim myoutlook As Object ' Outlook.Application
Dim r As Long
Dim myapt As Object ' Outlook.AppointmentItem
' late bound constants
Const olAppointmentItem = 1
Const olBusy = 2
Const olMeeting = 1
' Create the Outlook session
Set myoutlook = CreateObject("Outlook.Application")
' Start at row 2
r = 2
Do Until Trim$(Cells(r, 1).Value) = ""
' Create the AppointmentItem
Set myapt = myoutlook.CreateItem(olAppointmentItem)
' Set the appointment properties
With myapt
.Subject = Cells(r, 1).Value
.Location = Cells(r, 2).Value
.Start = Cells(r, 3).Value
.End = Cells(r, 4).Value
.Recipients.Add Cells(r, 8).Value 'this line will be repeated for each column that has email adresses
.MeetingStatus = olMeeting
' myapt.Recipients.ResolveAll
.AllDayEvent = Cells(r, 9).Value
' If Busy Status is not specified, default to 2 (Busy)
If Len(Trim$(Cells(r, 5).Value)) = 0 Then
.BusyStatus = olBusy
Else
.BusyStatus = Cells(r, 5).Value
End If
If Cells(r, 6).Value > 0 Then
.ReminderSet = True
.ReminderMinutesBeforeStart = Cells(r, 6).Value
Else
.ReminderSet = False
' now is the point where i would like that the code only reads new entries to the worksheet and not repeat reminders for already created items
' i think it has something to do with conditional formating
End If
I have a problem that i can't solve.
I have a excel sheet that run's a macro every time a close it.
The macro (that i found online) creates an event in Outlook calendars of diferent recipients.
The problem is that every time i open the sheet and add a new event, the macro repeats the alreday created events when i just want it to add the newest event.
I am not a programer and don't know how to code so please be patiente
I have this VBA code and it works for me but i don't know how to add the conditional format to make the macro run only on the most recent events.
can anyone please help??? here is the code
VBA Code:
Option Explicit
Sub AddAppointments()
Dim myoutlook As Object ' Outlook.Application
Dim r As Long
Dim myapt As Object ' Outlook.AppointmentItem
' late bound constants
Const olAppointmentItem = 1
Const olBusy = 2
Const olMeeting = 1
' Create the Outlook session
Set myoutlook = CreateObject("Outlook.Application")
' Start at row 2
r = 2
Do Until Trim$(Cells(r, 1).Value) = ""
' Create the AppointmentItem
Set myapt = myoutlook.CreateItem(olAppointmentItem)
' Set the appointment properties
With myapt
.Subject = Cells(r, 1).Value
.Location = Cells(r, 2).Value
.Start = Cells(r, 3).Value
.End = Cells(r, 4).Value
.Recipients.Add Cells(r, 8).Value 'this line will be repeated for each column that has email adresses
.MeetingStatus = olMeeting
' myapt.Recipients.ResolveAll
.AllDayEvent = Cells(r, 9).Value
' If Busy Status is not specified, default to 2 (Busy)
If Len(Trim$(Cells(r, 5).Value)) = 0 Then
.BusyStatus = olBusy
Else
.BusyStatus = Cells(r, 5).Value
End If
If Cells(r, 6).Value > 0 Then
.ReminderSet = True
.ReminderMinutesBeforeStart = Cells(r, 6).Value
Else
.ReminderSet = False
' now is the point where i would like that the code only reads new entries to the worksheet and not repeat reminders for already created items
' i think it has something to do with conditional formating
End If