How to Count Selected Emails in Outlook


Often you may want to count the number of selected emails in Outlook.

The best way to do so is by using a simple script in VBA.

The following step-by-step example shows exactly how to do so.

Note: You do not need any prior knowledge of VBA to use the code in this example. You will simply copy and paste the code provided.

Example: How to Count Selected Emails in Outlook

First, open Outlook.

Then, type Alt + F11. This will bring up the VBA Editor.

Next, click the Insert tab, then click Module:

Next, paste the following code into the Module window:

Sub CountEmails()
    Dim objSelection As Outlook.Selection
    Dim emailCount As Long
    Dim item As Object
    
    Set objSelection = Application.ActiveExplorer.Selection
    emailCount = 0
    
    For Each item In objSelection
        If TypeOf item Is Outlook.MailItem Then
            emailCount = emailCount + 1
        End If
    Next item
    
    MsgBox "You have selected " & emailCount & " emails."
End Sub

The following screenshot shows how to do so:

Next, close out of the VBA Editor.

Once you’re back in Outlook, hold Ctrl and select as many emails as you would like. For this example, we will select 6 emails.

Then type Alt + F8. Then click CountEmails. Then click Run.

Once you click Run, a message box will appear that tells you how many emails you have selected:

Outlook count selected emails

The message box correctly tells us that we have selected 6 emails.

Feel free to type Alt+F8 to use this VBA code whenever you would like to count the number of emails you have selected in Outlook.

Related Tutorials

The following tutorials explain how to perform other common tasks in Outlook:

Outlook: How to Search Emails by Date Range
Outlook: How to Search for Multiple Keywords in Emails
Outlook: How to Search for Emails with Attachments

Leave a Reply