• Outlook User
  • New Outlook app
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
  • Developer
  • Microsoft 365 Admin
    • Common Problems
    • Microsoft 365
    • Outlook BCM
    • Utilities & Addins

How to print a list of recurring dates using VBA

Slipstick Systems

› Developer › How to print a list of recurring dates using VBA

Last reviewed on January 13, 2021     11 Comments

Applies to: Outlook (classic), Outlook 2007, Outlook 2010

Like the macro that creates copies of each occurrence in a series, this macro gets the dates of each occurrence, printing it to a new message instead of creating appointments.
list individual occurrences

See Copy Recurring Appointment Series to Appointments for ways you can tweak the dates. To copy a single occurrence, see Copy Selected Occurrence to an Appointment.

Using the macro

However, the filter (sFilter) needs to be edited for older versions, as [IsRecurring] does not work. Use this instead:

sFilter = "[Start] >= '1/1/2000' And [End] < '" & tEnd & "' And [Subject] = " & strSubject

Also, leading or ending spaces (" My Appointment" or "My Appointment ") in the subject will cause the macro to fail, returning 0 appointments found. Removing the spaces from the subject should take care of it. You could move or copy the recurring appointment to a new Calendar folder and remove the subject filter.

Print a list of all dates in a series

Open the VBA Editor using Alt+F11. Expand the Project to display ThisOutlookSession on the left. Double click to open it and paste the code below into the right side. Select a calendar folder then run the macro.

As written, this macro limits the events to the next 10 days. You can increase or decrease this by changing the number of days in the future here:

tEnd = Format(Now + 10, "Short Date")

To use, select a recurring appointment or meeting and run the macro.

I highly recommend using list view when you use this macro.

Sub PrintRecurring()
   
   Dim CalFolder As Outlook.MAPIFolder
   Dim CalItems As Outlook.Items
   Dim ResItems As Outlook.Items
   Dim sFilter, strSubject, strOccur As String
   Dim iNumRestricted As Integer
   Dim itm, ListAppt As Object
   Dim tStart, tEnd As Date
 
   ' Use the selected calendar folder
   Set CalFolder = Application.ActiveExplorer.CurrentFolder
   Set CalItems = CalFolder.Items

   ' Sort all of the appointments based on the start time
   CalItems.Sort "[Start]"
   CalItems.IncludeRecurrences = True

   ' Set an end date
    tEnd = Format(Now + 10, "Short Date")
    
    strSubject = Application.ActiveExplorer.Selection.Item(1).Subject

   'create the Restrict filter by day and recurrence
   sFilter = "[Start] >= '1/1/2000' And [End] < '" & tEnd & "' And  [IsRecurring]  = True And [Subject] = " & strSubject

   Set ResItems = CalItems.Restrict(sFilter)

   iNumRestricted = 0

   'Loop through the items in the collection.
   For Each itm In ResItems
      iNumRestricted = iNumRestricted + 1
      
 ' Create list of dates
 strOccur = strOccur & vbCrLf & itm.Subject & vbTab & " >> " & vbTab & Format(itm.Start, "mm/dd/yyyy hh:mm AM/PM") & vbTab & " to: " & vbTab & Format(itm.End, "mm/dd/yyyy hh:mm AM/PM")

   Next
   
' After the last occurence is checked
' Open a new email message form and insert the list of dates
  Set ListAppt = Application.CreateItem(olMailItem)
  ListAppt.Body = strOccur & vbCrLf & iNumRestricted & " occurrences found."
  ListAppt.Display

   Set itm = Nothing
   Set ListAppt = Nothing
   Set ResItems = Nothing
   Set CalItems = Nothing
   Set CalFolder = Nothing
   
End Sub

 

List all events this year

This version of the macro list all events in this calendar year. All day events display the day only. Multiple day events are listed by day, although not sorted by day. If you want multiple day events listed once, the macro can easily be changed.
macro sample

Use an If statement to filter by a keyword or subject. (The sample macro below filters for the word vacation anywhere in the subject.)
If itm.Categories = "Vacation" Then
If InStr(1, LCase(itm.Subject), "vacation") > 0 Then

Sub ListAllAppts()
   
   Dim CalFolder As Outlook.MAPIFolder
   Dim CalItems As Outlook.Items
   Dim ResItems As Outlook.Items
   Dim sFilter, strSubject, strOccur As String
   Dim iNumRestricted As Integer
   Dim itm, ListAppt As Object
   Dim tStart As Date, tEnd As Date
    Dim strStart As String
    Dim mStart As Date

   ' Use the selected calendar folder
   Set CalFolder = Application.ActiveExplorer.CurrentFolder
   Set CalItems = CalFolder.Items

   ' Sort all of the appointments based on the start time
   CalItems.Sort "[Start]"
   CalItems.IncludeRecurrences = True

   ' Set start end date
    tStart = Format(Date, "1/1/yyyy")
    tEnd = Format(Date, "12/31/yyyy")
    
   sFilter = "[Start] >= '" & tStart & "' And [End] < '" & tEnd & "'"
Debug.Print sFilter
   Set ResItems = CalItems.Restrict(sFilter)

   iNumRestricted = 0

   'Loop through the items in the collection.
   For Each itm In ResItems
      iNumRestricted = iNumRestricted + 1
   
'use if filtering by category or subject
'If itm.Categories = "Vacation" Then
'If InStr(1, LCase(itm.Subject), "vacation") > 0 Then
 
' prettify the date & times
If itm.AllDayEvent = True Then
 mStart = Format(itm.Start, "m/d/yyyy")
 strEnd = "All Day Event, ending: " & Format(itm.End - 1, " m/d/yyyy")
 Else
 mStart = Format(itm.Start, "m/d/yyyy hh:mm AM/PM")
 strEnd = " To: " & Format(itm.End, " m/d/yyyy h:mm AM/PM")
End If

' Create list of dates
' list multiple day events by day
If itm.duration > 1440 Then
For i = 1 To itm.duration / 1440
strOccur = strOccur & vbCrLf & itm.Subject & vbTab & " >> " & vbTab & mStart & vbTab & strEnd
mStart = mStart + 1
Next
Else
' not multiple day
 strOccur = strOccur & vbCrLf & itm.Subject & vbTab & " >> " & vbTab & mStart & vbTab & strEnd
End If

' remove the If statement block above and use just this line for one entry for multiple day events:
' strOccur = strOccur & vbCrLf & itm.Subject & vbTab & " >> " & vbTab & mStart & vbTab & strEnd

'use with category/subject filter
'End If

Next
   
' After the last occurence is checked
' Open a new email message form and insert the list of dates
  Set ListAppt = Application.CreateItem(olMailItem)
  ListAppt.Body = strOccur & vbCrLf & iNumRestricted & " occurrences found."
  ListAppt.Display

   Set itm = Nothing
   Set ListAppt = Nothing
   Set ResItems = Nothing
   Set CalItems = Nothing
   Set CalFolder = Nothing
   
End Sub

How to use the macros on this page

First: You need to have macro security set to the lowest setting, Enable all macros during testing. The macros will not work with the top two options that disable all macros or unsigned macros. You could choose the option Notification for all macros, then accept it each time you restart Outlook, however, because it's somewhat hard to sneak macros into Outlook (unlike in Word and Excel), allowing all macros is safe, especially during the testing phase. You can sign the macro when it is finished and change the macro security to notify.

To check your macro security in Outlook 2010 and newer, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, look at Tools, Macro Security.

After you test the macro and see that it works, you can either leave macro security set to low or sign the macro.

The macros on this page should be placed in a module.

Open the VBA Editor by pressing Alt+F11 on your keyboard.

To put the code in a module:

  1. Right click on Project1 and choose Insert > Module
  2. Copy and paste the macro into the new module.

More information as well as screenshots are at How to use the VBA Editor

How to print a list of recurring dates using VBA was last modified: January 13th, 2021 by Diane Poremsky

Related Posts:

  • Copy Recurring Appointment Series to Appointments
  • Delete Old Calendar Events using VBA
  • Use VBA to Email Tomorrow's Agenda
  • Search Calendars for Appointments

About Diane Poremsky

A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Subscribe
Notify of
11 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Cory (@guest_211776)
August 24, 2018 12:06 pm
#211776

i know this is an old thread, but it's been a great help.

i get an error message when using this macro with a number at the start of the subject.
is there a fix for this?

Thanks

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Cory
August 24, 2018 11:12 pm
#211783

what is the error message?

0
0
Reply
Cory (@guest_211827)
Reply to  Diane Poremsky
August 29, 2018 12:57 pm
#211827

here is the error message i am receiving

Run-time error '-2147352567 (80020009)':

Cannot parse condition. Error at ":30".

Capture.JPG
0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Cory
January 3, 2019 3:35 pm
#212476

Sorry I missed this before. Do you know what line it quit on? It looks like a problem with a time.

0
0
Reply
JD (@guest_176780)
May 10, 2013 4:07 am
#176780

Silly Question it was....;) it get Resolved Diane...Thanks....

0
0
Reply
WCR (@guest_211824)
Reply to  JD
August 29, 2018 8:17 am
#211824

What was the solution? I also have recursive and nonrecursive.

0
0
Reply
JD (@guest_176778)
May 10, 2013 2:37 am
#176778

Hi Diane,
Tricky resolution. :)
This code only adds the recursive items. I am applying includerecurrences=false in if condition stil it is not able to sort non-recursive. How could we fetch recursive as well as non-recursive items on the fly..

0
0
Reply
rich (@guest_137667)
June 20, 2012 3:55 am
#137667

I'm using Outlook 2007 sp3 mso (12.0.6607.1000) at work (us army). when i run this macro it always says 0 occurrences no matter which item i have selected (in list view).

Am I doing something wrong ?

Thanks

1
-1
Reply
Diane Poremsky (@guest_137823)
Reply to  rich
June 20, 2012 7:16 am
#137823

I'm looking into it. The problem is with the restrict filter - it's not working with the subject and isrecurring field - this works, but includes all appt in Outlook 2007 and under.
sFilter = "[Start] >= '1/1/2000' And [End] < '" & tEnd & "'"

1
-2
Reply
Diane Poremsky (@guest_137871)
Reply to  Diane Poremsky
June 20, 2012 8:03 am
#137871

Correction - subject works but leading or ending spaces cause it to fail. As long as you don't have single appt with the same subject, the IsRecurring isn't necessary.
sFilter = "[Start] >= '1/1/2000' And [End] < '" & tEnd & "' And [Subject] = " & strSubject

2
-2
Reply
Joel Kotarski (@guest_213967)
Reply to  Diane Poremsky
September 19, 2019 11:22 am
#213967

Hi there. Got it fixed - just do this:
sFilter = "[Start] >= '1/1/2000' And [End] < '" & tEnd & "' And [IsRecurring] = True And [Subject] = '" & strSubject & "'"

1
0
Reply

Visit Slipstick Forums.
What's New at Slipstick.com

Latest EMO: Vol. 30 Issue 19

Subscribe to Exchange Messaging Outlook






Support Services

Do you need help setting up Outlook, moving your email to a new computer, migrating or configuring Office 365, or just need some one-on-one assistance?

Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • Week Month All
  • Jetpack plugin with Stats module needs to be enabled.
  • Open Outlook Templates using PowerShell
  • Count and List Folders in Classic Outlook
  • Google Workspace and Outlook with POP Mail
  • Import EML Files into New Outlook
  • Opening PST files in New Outlook
  • New Outlook: Show To, CC, BCC in Replies
  • Insert Word Document into Email using VBA
  • Delete Empty Folders using PowerShell
  • Warn Before Deleting a Contact
  • Classic Outlook is NOT Going Away in 2026
Ajax spinner

Recent Bugs List

Microsoft keeps a running list of issues affecting recently released updates at Fixes or workarounds for recent issues in classic Outlook (Windows).

For new Outlook for Windows: Fixes or workarounds for recent issues in new Outlook for Windows .

Outlook for Mac Recent issues: Fixes or workarounds for recent issues in Outlook for Mac

Outlook.com Recent issues: Fixes or workarounds for recent issues on Outlook.com

Office Update History

Update history for supported Office versions is at Update history for Office

Outlook Suggestions and Feedback

Outlook Feedback covers Outlook as an email client, including Outlook Android, iOS, Mac, and Windows clients, as well as the browser extension (PWA) and Outlook on the web.

Outlook (new) Feedback. Use this for feedback and suggestions for Outlook (new).

Use Outlook.com Feedback for suggestions or feedback about Outlook.com accounts.

Other Microsoft 365 applications and services




New Outlook Articles

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Google Workspace and Outlook with POP Mail

Import EML Files into New Outlook

Opening PST files in New Outlook

New Outlook: Show To, CC, BCC in Replies

Insert Word Document into Email using VBA

Delete Empty Folders using PowerShell

Warn Before Deleting a Contact

Classic Outlook is NOT Going Away in 2026

Newest Code Samples

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Insert Word Document into Email using VBA

Warn Before Deleting a Contact

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Change the Mailing Address Using PowerShell

Categorize @Mentioned Messages

Send an Email When You Open Outlook

Delete Old Calendar Events using VBA

VBA Basics

How to use the VBA Editor

Work with open item or selected item

Working with All Items in a Folder or Selected Items

VBA and non-default Outlook Folders

Backup and save your Outlook VBA macros

Get text using Left, Right, Mid, Len, InStr

Using Arrays in Outlook macros

Use RegEx to extract message text

Paste clipboard contents

Windows Folder Picker

Custom Forms

Designing Microsoft Outlook Forms

Set a custom form as default

Developer Resources

Developer Resources

Developer Tools

VBOffice.net samples

SlovakTech.com

Outlook MVP David Lee

Repair PST

Convert an OST to PST

Repair damaged PST file

Repair large PST File

Remove password from PST

Merge Two Data Files

Sync & Share Outlook Data

  • Share Calendar & Contacts
  • Synchronize two computers
  • Sync Calendar and Contacts Using Outlook.com
  • Sync Outlook & Android Devices
  • Sync Google Calendar with Outlook
  • Access Folders in Other Users Mailboxes

Diane Poremsky [Outlook MVP]

Make a donation

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Productivity

Productivity Tools

Automatic Message Processing Tools

Special Function Automatic Processing Tools

Housekeeping and Message Management

Task Tools

Project and Business Management Tools

Choosing the Folder to Save a Sent Message In

Run Rules on messages after reading

Help & Suggestions

Submit Outlook Feature Requests

Slipstick Support Services

Buy Microsoft 365 Office Software and Services

Visit Slipstick Forums.

What's New at Slipstick.com

Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer
Outlook for Mac | Common Problems | Utilities & Addins | Tutorials
Outlook & iCloud Issues | Outlook Apps
EMO Archives | About Slipstick | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2025 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.

wpDiscuz

Sign up for Exchange Messaging Outlook

Our weekly Outlook & Exchange newsletter (bi-weekly during the summer)






Please note: If you subscribed to Exchange Messaging Outlook before August 2019, please re-subscribe.

Never see this message again.

You are going to send email to

Move Comment