Getting Excel Dates into Outlook's Calendar

Written by Allen Wyatt (last updated February 23, 2019)
This tip applies to Excel 97, 2000, 2002, and 2003


7

Kelly has a worksheet in which she has a table of dates used as closing dates for getting advertisements into the local Yellow Pages. She wants to import these dates into Outlook Calendar with a 72-hour reminder, but some of the dates keep changing to numbers. Kelly wonders how she can get the Excel dates into Outlook like she needs.

Working with Outlook is a bit "higher level" than your run-of-the-mill Excel macro because you need to understand not only how to access Excel data in the macro, but also how to manipulate Outlook data. Without knowing exactly what data you need to transfer from the worksheet to the Outlook appointment, let's examine a short scenario.

Let's assume that you have a worksheet that contains a series of rows, each of which represents a single appointment you want to create. Each appointment contains information in seven columns, as follows, from left to right:

  • Subject. Text that describes the event/appointment (for example, "Yellow Pages Reminder")
  • Location. Text that describes the location of the event, such as a meeting room or a conference call number (this is optional)
  • Start Date/Time. Enter the date and time the event should start using a standard Excel date format (you can display any way you like)
  • Duration. Integer that represents a number of minutes for the appointment
  • Busy Status. Integer that represents an optional value indicating if the time should show as Free (0), Tentative (1), Busy (2), or Out of Office (3)
  • Reminder Time. Integer that represents a number of minutes before the appointment that a reminder should pop-up (as in 4320 which is the number of minutes in 3 days)
  • Body. Text that describes any detail you might want to place in the body of the appointment

With this data in place, you can use a macro to loop through all the rows (starting with the second row, assuming the first row has headings) and create an appointment for each row.

Sub AddAppointments()
    ' 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(1)
        ' Set the appointment properties
        myApt.Subject = Cells(r, 1).Value
        myApt.Location = Cells(r, 2).Value
        myApt.Start = Cells(r, 3).Value
        myApt.Duration = Cells(r, 4).Value
        ' If Busy Status is not specified, default to 2 (Busy)
        If Trim(Cells(r, 5).Value) = "" Then
            myApt.BusyStatus = 2
        Else
            myApt.BusyStatus = Cells(r, 5).Value
        End If
        If Cells(r, 6).Value > 0 Then
            myApt.ReminderSet = True
            myApt.ReminderMinutesBeforeStart = Cells(r, 6).Value
        Else
            myApt.ReminderSet = False
        End If
        myApt.Body = Cells(r, 7).Value
        myApt.Save
        r = r + 1
    Loop
End Sub

The macro continues to loop through the rows until the Subject column is empty.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (7349) applies to Microsoft Excel 97, 2000, 2002, and 2003.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Seeing Full File Names in the Files Menu

Wouldn't it be great if you could look at the files in the MRU list and see the full path and file names? Excel condenses ...

Discover More

Extracting E-mail Addresses from Hyperlinks

If you have a list of hyperlinked e-mail addresses in a worksheet, you may want to extract the addresses from those ...

Discover More

Two Page Numbers per Physical Page

Want to save paper when printing your document? Just print two pages per sheet of paper and you'll get rid of only half ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 2 + 2?

2021-06-07 15:18:45

Laura Samuelson

This works perfectly in my personal calendar; how can this code be modified to send the appointments to a shared calendar?


2020-10-30 14:53:31

Tara

I am trying to incorporate the above into a spreadsheet for my team, however, it will be a "running log" of requests issued and due dates. Therefore, the macro is adding duplicate appointments. Is there any code that can be added to only add new entries/appointments to the calendar?


2019-09-04 11:41:40

Shawn

Hi, do you have examples of how to make this work on a Mac? I'm getting a runtime error. Looks like it's something to do with creating the Outlook Object.


2019-08-12 08:24:34

Avinash Prakash

Dear Allen

Would you also be able to write a code that deletes a particular appointment?
The ideal filters would be the same as adding the appointments (BY Subject, date, and perhaps category)

I'v been trying to use a lot of different ways, but none as simple and efficent as yours.


2019-07-12 06:55:07

Jonathan

Hi Allen,

This is great and really helpful, what do i need to add to the macro or sheet if i want to use a sub calendar rather than my main?

Thanks


2019-06-19 12:17:20

Cinthia

Good, but I have a question: if I want to add an appointment into a calendar with a customized template, how can I do it? I selected the module into calendar properties. So I assume that default properties let me to insert calendar appointment by its customized module from excel macro too, but not it is.
Someone can help me please?


2019-05-10 21:28:00

Singgih

dear Allen
thank you for the code. I have a problem as it failed to implemented. (run-time error '-21447467263 (80004001)' : Not implemented.
when I press the debug button it highlights the "myApt.Save" line code.
could you give solution of this issue?
regards


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.