Hi,
If you only need to count these emails then I think it would be easier to use the advanced filter.
You won't need to loop through all emails in the folder to get the count, so if you are using this to handle large numbers of emails you should see improvement in speed as well.
Basically, this method works the same as if you typed your search criteria into Outlook search box and read the number of results from the status bar.
I've modified your code below, see if it works for you.
The backlog count is displayed in a message box, change this to wherever you need it.
Lastly, the inputbox will currently accept any input so you are probably right leaving the error handler on till the end of the code, but that's not ideal.
Greetings from Bray!
Bookmarks