How to count distribution list members in Outlook?
In Outlook, there’s no feature for you to count the distribution list members directly. If you have a distribution list with large amount of email addresses, how to find out that how many members are included in this group? With this article, you will learn how to count distribution list members with using VBA code.
Count distribution list members in Outlook with VBA code
Add a button for the macro to the Quick Access Toolbar
- Automate emailing with Auto CC/BCC, Auto Forward by rules; send Auto Reply (Out of Office) without requiring an exchange server...
- Get reminders like BCC Warning when replying to all while you're in the BCC list, and Remind When Missing Attachments for forgotten attachments...
- Improve email efficiency with Reply (All) With Attachments, Auto Add Greeting or Date & Time into Signature or Subject, Reply Multiple Emails...
- Streamline emailing with Recall Emails, Attachment Tools (Compress All, Auto Save All...), Remove Duplicates, and Quick Report...
Count distribution list members in Outlook with VBA code
You can use VBA code to count the distribution list members as follows.
1. Open the Microsoft Visual Basic for Applications window with pressing the Alt + F11 keys on the keyboard at the same time.
2. Click Insert > Module. See screenshot:
3. Then copy and paste the following VBA code into the VbaProject window.
VBA: Count distribution list members in Outlook
Sub CountDLMembers()
Dim oOL As Outlook.Application
Dim oSelection As Outlook.Selection
Dim oItem As Object
Dim olDL As Outlook.DistListItem
Dim Result As String
Set oOL = Outlook.Application
'Check and get the selected Contact Group
Select Case TypeName(oOL.ActiveWindow)
Case "Explorer"
Set oSelection = oOL.ActiveExplorer.Selection
If oSelection.Count > 0 Then
Set oItem = oSelection.Item(1)
Else
Result = MsgBox("No item selected. " & _
"Please select a Contact Group first.", _
vbCritical, "CountDLMembers")
Exit Sub
End If
Case "Inspector"
Set oItem = oOL.ActiveInspector.CurrentItem
Case Else
Result = MsgBox("Unsupported Window type." & _
vbNewLine & "Please make a selection" & _
"in the Calendar or open a Contact Group first.", _
vbCritical, "CountDLMembers")
Exit Sub
End Select
If oItem.Class = Outlook.olDistributionList Then
'Display the member count
Set olDL = oItem
Result = MsgBox("The Contact Group '" & olDL.DLName & "' contains " & olDL.MemberCount & " members.", vbInformation, "CountDLMembers")
Else
'Selected item isn't a Contact Group item
Result = MsgBox("No Contact Group item selected. " & _
"Please make a selection first.", _
vbCritical, "CountDLMembers")
Exit Sub
End If
'Cleanup
Set oOL = Nothing
Set olDL = Nothing
End Sub
4. Then click the Save button to save it.
5. Close the Microsoft Visual Basic for Applications window.
Add a button for the macro to the Quick Access Toolbar
1. Go to the Contacts or People view by clicking the Contacts or People in the Navigation Pane.
2. In Outlook 2010 and 2013, please right click on the Quick Access Toolbar and then click Customize Quick Access Toolbar in the right-clicking menu. See screenshot:
Note: In Outlook 2007, please open a distribution list, and then right click on the Quick Access Toolbar to select the Quick Access Toolbar in the right-clicking menu.
3. In the Outlook Options dialog box, you need to:
1). Make sure that you are locating in the Quick Access Toolbar section;
2). Select Macros in the Choose commands from drop-down list;
3). Select the macros in the Separator box;
4). Click the Add button;
5). And finally click the OK button. See screenshot:
4. Then you can see the button for the macro is added on the Quick Access Toolbar.
After adding the button for the macro on the Quick Access Toolbar, now you can run the VBA code to count the distribution list members.
1. In Outlook 2010 and 2013, you can just select a distribution list, and then click the button for the macro on the Quick Access Toolbar.
Note: In Outlook 2007, you need to open a distribution list and then click the button for the macro on the Quick Access Toolbar.
2. Then a prompt box will pop up to tell you how many members are contained in this distribution list. Then click the OK.
Best Office Productivity Tools
Kutools for Outlook - Over 100 Powerful Features to Supercharge Your Outlook
🤖 AI Mail Assistant: Instant pro emails with AI magic--one-click to genius replies, perfect tone, multilingual mastery. Transform emailing effortlessly! ...
📧 Email Automation: Out of Office (Available for POP and IMAP) / Schedule Send Emails / Auto CC/BCC by Rules When Sending Email / Auto Forward (Advanced Rules) / Auto Add Greeting / Automatically Split Multi-Recipient Emails into Individual Messages ...
📨 Email Management: Easily Recall Emails / Block Scam Emails by Subjects and Others / Delete Duplicate Emails / Advanced Search / Consolidate Folders ...
📁 Attachments Pro: Batch Save / Batch Detach / Batch Compress / Auto Save / Auto Detach / Auto Compress ...
🌟 Interface Magic: 😊More Pretty and Cool Emojis / Boost Your Outlook Productivity with Tabbed Views / Minimize Outlook Instead of Closing ...
👍 One-click Wonders: Reply All with Incoming Attachments / Anti-Phishing Emails / 🕘Show Sender's Time Zone ...
👩🏼🤝👩🏻 Contacts & Calendar: Batch Add Contacts From Selected Emails / Split a Contact Group to Individual Groups / Remove Birthday Reminders ...
Over 100 Features Await Your Exploration! Click Here to Discover More.