excel count if


I need find an efficient way to search daily exchange log files to monitor the number of emails sent with a particular email subject.

In the attached excel model:

Sheet1 is the exchanges logs that could have 50,000 lines
Sheet2 is an example of what I would link to finish with

Sheet2  B2 =

sheet1, column S =  Copy Invoice for Company A
sheet1, column T = A@exchange.co.uk
total number of es1100.mail.exchange.co.uk in sheet1, column E
In this example the total is 1
Sheet2  B3 =

sheet1, column S =  Copy Invoice for Company B
sheet1, column T = B@exchange.co.uk
total number of es1100.mail.exchange.co.uk in sheet1, column E
In this example the total is 2
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hellblazerukAuthor Commented:
Glenn RayExcel VBA DeveloperCommented:
You can use the COUNTIFS function in Excel 2010/2013 to solve this.  For B2 (Company A), it would look like:
=COUNTIFS(Sheet1!S:S," Copy Invoice for Company A",Sheet1!T:T,"A@exchange.co.uk",Sheet1!E:E,"es1100.mail.exchange.co.uk")

and for B3 (Company B)
=COUNTIFS(Sheet1!S:S," Copy Invoice for Company B",Sheet1!T:T,"B@exchange.co.uk",Sheet1!E:E,"es1100.mail.exchange.co.uk")

However, it looks like you're using an earlier version of Excel, so you'll need to use a SUMPRODUCT function instead.

=SUMPRODUCT(--(Sheet1!$S$2:$S$100=" Copy Invoice for Company A"),--(Sheet1!$T$2:$T$100="A@exchange.co.uk"),--(Sheet1!$E$2:$E$100="es1100.mail.exchange.co.uk"))
=SUMPRODUCT(--(Sheet1!$S$2:$S$100=" Copy Invoice for Company B"),--(Sheet1!$T$2:$T$100="B@exchange.co.uk"),--(Sheet1!$E$2:$E$100="es1100.mail.exchange.co.uk"))

You could make these simpler and more dynamic by adding the test values to the right and pointing there instead.  I've attached a modified version of your file to demonstrate.

1) The message subject text has a leading space and it's included in the above formulas
2) The example formulas only check to row 100; change that value as needed for your actual data.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.