---
description: If you have multiple subfolders under a certain folder and now you want to count the items in this folder and all its subfolders, you can use the way introduced in this article.
title: How to Quickly Get the Total Count of Items in a Folder and All Its Subfolders via Outlook VBA
image: https://www.datanumen.com/blogs/wp-content/uploads/2017/05/quickly-get-the-total-count-of-items-in-a-folder-and-all-its-subfolders-via-outlook-vba.jpg
---

-
-
-

[Home](https://www.datanumen.com/blogs/) > [Solutions](https://www.datanumen.com/blogs/category/solutions/) > [Office Solutions](https://www.datanumen.com/blogs/category/solutions/office-solutions/) > [Outlook Solutions](https://www.datanumen.com/blogs/category/solutions/office-solutions/outlook-solutions/) > How to Quickly Get the Total Count of Items in a Folder and All Its Subfolders via Outlook VBA

# How to Quickly Get the Total Count of Items in a Folder and All Its Subfolders via Outlook VBA

[Outlook Solutions](https://www.datanumen.com/blogs/category/solutions/office-solutions/outlook-solutions/) September 29, 2025

Share Now:

-
-
-
-
-
-
-
-

*If you have multiple subfolders under a certain folder and now you want to count the items in this folder and all its subfolders, you can use the way introduced in this article.*

![Quickly Get the Total Count of Items in a Folder and All Its Subfolders via Outlook VBA](https://www.datanumen.com/blogs/wp-content/uploads/2017/05/quickly-get-the-total-count-of-items-in-a-folder-and-all-its-subfolders-via-outlook-vba-300x255.jpg "Quickly Get the Total Count of Items in a Folder and All Its Subfolders via Outlook VBA")In general, to check the total count of items in one folder, you have two ways. One is to select this folder and then you can view the count of items in the lower-left corner of status bar. The other one is to change folder properties to set it to show total number of items. However, if there are several subfolders under this folder, both the two means above are incapable of including the subfolders in counting. Therefore, if you would like to get the total count of items in a folder and all its subfolders, you need to seek other means, such as the following one. It is utilizing VBA code to quickly achieve such a total count. Please read on to get its elaborate steps and VBA codes.

## Get the Total Count of Items in a Folder and All Its Subfolders

1. At the very outset, you can start your Outlook program as usual.
2. Then press “Alt + F11” key buttons to show Outlook VBA editor.
3. Next you can open an empty module.
4. Subsequently, copy and paste the following VBA codes into this module.

```
Sub CountItems()
    Dim objMainFolder As Outlook.Folder
    Dim lItemsCount As Long
 
    'Select a folder
    Set objMainFolder = Outlook.Application.Session.PickFolder
 
    If objMainFolder Is Nothing Then
       MsgBox "You choose select a valid folder!", vbExclamation + vbOKOnly, "Warning for Pick Folder"
    Else
       'Initialize the total count
       lItemsCount = 0
       Call LoopFolders(objMainFolder, lItemsCount)
    End If
 
    'Display a message for the total count
    MsgBox "There are " & lItemsCount & " items in the " & objMainFolder.Name & " folder Including its subfolders.", vbInformation, "Count Items"
End Sub

Sub LoopFolders(ByVal objCurrentFolder As Outlook.Folder, lCurrentItemsCount As Long)
    Dim objSubfolder As Outlook.Folder
 
    lCurrentItemsCount = lCurrentItemsCount + objCurrentFolder.Items.Count
 
    'Process all folders and subfolders recursively
    If objCurrentFolder.Folders.Count Then
       For Each objSubfolder In objCurrentFolder.Folders
           Call LoopFolders(objSubfolder, lCurrentItemsCount)
       Next
    End If
End Sub
```

![VBA Code - Get the Total Count of Items in a Folder and All Its Subfolders]( "VBA Code - Get the Total Count of Items in a Folder and All Its Subfolders")

5. After that, you should change your Outlook macro security level to low.
6. Finally you can have a try.

- In the new macro window, press F5 key button.
- At once, you will be required to select a folder.![Select a Folder]( "Select a Folder")
- Immediately, you will receive a new message prompting the total count of the items in the selected folder and all its subfolders, like the picture below:![Count Items]( "Count Items")

## Archive Old Items in Time

It is always suggested to archive the old items in your PST file as soon as possible. Otherwise, with more and more items accumulating in this file, it will be prone to errors and corruptions. Once your PST file gets compromised, you will spend lots of efforts getting back the [corrupt Outlook](https://www.datanumen.com/outlook-repair/) data. It’ll be pretty difficult unless you recur to an experienced tool like DataNumen Outlook Repair.

## Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including [corrupt SQL Server](https://www.datanumen.com/sql-recovery/) and outlook repair software products. For more information visit [www.datanumen.com](https://www.datanumen.com/)

Share Now:

-
-
-
-
-
-
-
-

[← Previous post](https://www.datanumen.com/blogs/unrar-rar-attachments-directly-outlook-via-vba/)

[Next post →](https://www.datanumen.com/blogs/2-quick-ways-find-delete-sentences-containing-specific-text-word/)

Comments are closed.

![Data Recovery Blog]()

Follow or like us on Facebook, LinkedIn and Twitter to get all promotions, latest news and updates on our products and company.

-
-
-

### Featured Products

- [DataNumen Outlook Repair](https://www.datanumen.com/outlook-repair/)
- [DataNumen SQL Recovery](https://www.datanumen.com/sql-recovery/)
- [DataNumen Exchange Recovery](https://www.datanumen.com/exchange-recovery/)
- [DataNumen Access Repair](https://www.datanumen.com/access-repair/)
- [DataNumen Excel Repair](https://www.datanumen.com/excel-repair/)
- [DataNumen PDF Repair](https://www.datanumen.com/pdf-repair/)
- [DataNumen Word Repair](https://www.datanumen.com/word-repair/)
- [DataNumen Zip Repair](https://www.datanumen.com/zip-repair/)

### Popular posts

```json
{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.datanumen.com\/blogs\/quickly-get-total-count-items-folder-subfolders-via-outlook-vba\/#article","isPartOf":{"@id":"https:\/\/www.datanumen.com\/blogs\/quickly-get-total-count-items-folder-subfolders-via-outlook-vba\/"},"author":{"name":"AuthorCCW","@id":"https:\/\/www.datanumen.com\/blogs\/#\/schema\/person\/33ded6c47c77587f9158d99f05e23957"},"headline":"How to Quickly Get the Total Count of Items in a Folder and All Its Subfolders via Outlook VBA","datePublished":"2017-05-16T03:05:11+00:00","dateModified":"2025-09-29T10:51:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.datanumen.com\/blogs\/quickly-get-total-count-items-folder-subfolders-via-outlook-vba\/"},"wordCount":410,"commentCount":1,"publisher":{"@id":"https:\/\/www.datanumen.com\/blogs\/#organization"},"image":{"@id":"https:\/\/www.datanumen.com\/blogs\/quickly-get-total-count-items-folder-subfolders-via-outlook-vba\/#primaryimage"},"thumbnailUrl":"https:\/\/www.datanumen.com\/blogs\/wp-content\/uploads\/2017\/05\/quickly-get-the-total-count-of-items-in-a-folder-and-all-its-subfolders-via-outlook-vba.jpg","articleSection":["Outlook Solutions"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.datanumen.com\/blogs\/quickly-get-total-count-items-folder-subfolders-via-outlook-vba\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.datanumen.com\/blogs\/quickly-get-total-count-items-folder-subfolders-via-outlook-vba\/","url":"https:\/\/www.datanumen.com\/blogs\/quickly-get-total-count-items-folder-subfolders-via-outlook-vba\/","name":"How to Quickly Get the Total Count of Items in a Folder and All Its Subfolders via Outlook VBA","isPartOf":{"@id":"https:\/\/www.datanumen.com\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.datanumen.com\/blogs\/quickly-get-total-count-items-folder-subfolders-via-outlook-vba\/#primaryimage"},"image":{"@id":"https:\/\/www.datanumen.com\/blogs\/quickly-get-total-count-items-folder-subfolders-via-outlook-vba\/#primaryimage"},"thumbnailUrl":"https:\/\/www.datanumen.com\/blogs\/wp-content\/uploads\/2017\/05\/quickly-get-the-total-count-of-items-in-a-folder-and-all-its-subfolders-via-outlook-vba.jpg","datePublished":"2017-05-16T03:05:11+00:00","dateModified":"2025-09-29T10:51:00+00:00","description":"If you have multiple subfolders under a certain folder and now you want to count the items in this folder and all its subfolders, you can use the way introduced in this article.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.datanumen.com\/blogs\/quickly-get-total-count-items-folder-subfolders-via-outlook-vba\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.datanumen.com\/blogs\/quickly-get-total-count-items-folder-subfolders-via-outlook-vba\/#primaryimage","url":"https:\/\/www.datanumen.com\/blogs\/wp-content\/uploads\/2017\/05\/quickly-get-the-total-count-of-items-in-a-folder-and-all-its-subfolders-via-outlook-vba.jpg","contentUrl":"https:\/\/www.datanumen.com\/blogs\/wp-content\/uploads\/2017\/05\/quickly-get-the-total-count-of-items-in-a-folder-and-all-its-subfolders-via-outlook-vba.jpg","width":705,"height":599,"caption":"Quickly Get the Total Count of Items in a Folder and All Its Subfolders via Outlook VBA"},{"@type":"WebSite","@id":"https:\/\/www.datanumen.com\/blogs\/#website","url":"https:\/\/www.datanumen.com\/blogs\/","name":"Data Recovery Blog","description":"Discuss every aspect of data recovery","publisher":{"@id":"https:\/\/www.datanumen.com\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.datanumen.com\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.datanumen.com\/blogs\/#organization","name":"Data Recovery Blog","url":"https:\/\/www.datanumen.com\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.datanumen.com\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/www.datanumen.com\/blogs\/wp-content\/uploads\/2019\/02\/logowithouttext.jpg","contentUrl":"https:\/\/www.datanumen.com\/blogs\/wp-content\/uploads\/2019\/02\/logowithouttext.jpg","width":296,"height":397,"caption":"Data Recovery Blog"},"image":{"@id":"https:\/\/www.datanumen.com\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataNumen","https:\/\/x.com\/DataNumen","http:\/\/www.linkedin.com\/company\/datanumen","https:\/\/myspace.com\/datanumen\/","http:\/\/www.pinterest.com\/datanumen\/","https:\/\/www.youtube.com\/channel\/UCVIIuuKfUBHSJauUaVP13tw"]},{"@type":"Person","@id":"https:\/\/www.datanumen.com\/blogs\/#\/schema\/person\/33ded6c47c77587f9158d99f05e23957","name":"AuthorCCW","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3516ed90fc242780d3947a989f895bc46e70c3e83485d30f2b457a007906aa58?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3516ed90fc242780d3947a989f895bc46e70c3e83485d30f2b457a007906aa58?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3516ed90fc242780d3947a989f895bc46e70c3e83485d30f2b457a007906aa58?s=96&d=mm&r=g","caption":"AuthorCCW"},"sameAs":["https:\/\/www.datanumen.com\/"]}]}
```
