I work for a recruitment firm and as such much of my day is spent calling numerous people. Many of these people are unable to talk at the present time and instruct me to call back days, weeks even months later.
I record all calls etc in an excel spreadsheet and would like to be add call back date and details then run a macro that puts an appointment in my outlook calendar.
I have written the following which works however is unable to skip blank cells (people who I do not need to call back)
Any assistance in fixing the code so I can run it and have it skip the blank cells between entries would be much appreciated.
Sub Outlook()
Sub AddAppointments()
' Create the Outlook session
Set myOutlook = CreateObject("Outlook.Application")
' Start at row 2
r = 2
Do Until Trim(Cells(r, 8).Value) = ""
If Cells(r, 8).Value <> "Done" Then
' Create the AppointmentItem
Set myApt = myOutlook.createitem(1)
' Set the appointment properties
myApt.Subject = Cells(r, 8).Value
myApt.Location = Cells(r, 9).Value
myApt.Start = Cells(r, 10).Value
myApt.Duration = Cells(r, 11).Value
' If Busy Status is not specified, default to 2 (Busy)
If Trim(Cells(r, 12).Value) = "" Then
myApt.BusyStatus = 2
Else
myApt.BusyStatus = Cells(r, 12).Value
End If
If Cells(r, 13).Value > 0 Then
myApt.ReminderSet = True
myApt.ReminderMinutesBeforeStart = Cells(r, 13).Value
Else
myApt.ReminderSet = False
End If
myApt.Body = Cells(r, 14).Value
myApt.Save
Cells(r, 15) = "Done" 'Enter "Done" in Col O when appointment is created
End If
r = r + 1
Loop
End Sub
The "Done" entry is to stop entries being duplicated upon subsequent runnings of the code
Thanks in advance for any help
I record all calls etc in an excel spreadsheet and would like to be add call back date and details then run a macro that puts an appointment in my outlook calendar.
I have written the following which works however is unable to skip blank cells (people who I do not need to call back)
Any assistance in fixing the code so I can run it and have it skip the blank cells between entries would be much appreciated.
Sub Outlook()
Sub AddAppointments()
' Create the Outlook session
Set myOutlook = CreateObject("Outlook.Application")
' Start at row 2
r = 2
Do Until Trim(Cells(r, 8).Value) = ""
If Cells(r, 8).Value <> "Done" Then
' Create the AppointmentItem
Set myApt = myOutlook.createitem(1)
' Set the appointment properties
myApt.Subject = Cells(r, 8).Value
myApt.Location = Cells(r, 9).Value
myApt.Start = Cells(r, 10).Value
myApt.Duration = Cells(r, 11).Value
' If Busy Status is not specified, default to 2 (Busy)
If Trim(Cells(r, 12).Value) = "" Then
myApt.BusyStatus = 2
Else
myApt.BusyStatus = Cells(r, 12).Value
End If
If Cells(r, 13).Value > 0 Then
myApt.ReminderSet = True
myApt.ReminderMinutesBeforeStart = Cells(r, 13).Value
Else
myApt.ReminderSet = False
End If
myApt.Body = Cells(r, 14).Value
myApt.Save
Cells(r, 15) = "Done" 'Enter "Done" in Col O when appointment is created
End If
r = r + 1
Loop
End Sub
The "Done" entry is to stop entries being duplicated upon subsequent runnings of the code
Thanks in advance for any help