Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Counting Employees in Classes.

Counting Employees in Classes

Written by Allen Wyatt (last updated April 23, 2024)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


3

Beth was looking for a way to determine how many employees had taken at least ten classes that were offered at her company. She set up Excel so that column A (beginning at A2) contained employee names, and column B (beginning at B2) contained class names. When an employee took a class, their name was entered in column A, and the name of the class they took was placed in column B. Thus, column A would contain multiple instances of each employee's name, and column B would contain multiple instances of class names.

The question of how to determine when an employee had taken ten classes can best be answered by using the COUNTIF function. For instance, the following formula could be entered in each cell of column C:

=IF(COUNTIF(A:A,A2)>9,"10 classes or more","")

In order to use the formula correctly, this particular instance would be placed in cell C2 and then copied down in the rest of column C's cells. This causes the A2 reference in the formula to change so that it always references the cell two columns to its immediate left. (The formula in C2 references A2, the formula in C3 references A3, etc.)

Using this formula, when a particular person has taken their tenth class—meaning that their name appears in column A for the tenth time—then column C fills up with the phrase "10 classes or more" next to each class that particular person took. This is great, except when a bunch of different employees start crossing the ten-class threshold. Then column C starts to look cluttered.

To overcome the clutter, a variation on the above approach is to use the following formula in the cells of column C:

=IF(COUNTIF($A$2:A2,A2)>9,"10 classes or more","")

In this instance, the COUNTIF function doesn't look at every cell in column A; instead it looks at the cells in column A that are in rows less than or equal to the row in which the formula occurs. Thus, if this formula was in row 8, then COUNTIF would only look at rows 2 through 8 in doing its count. The result is that the phrase "10 classes or more" only appears in column C when a particular employee has passed the ten-class mark. It will not appear for instances where the employee was taking their first, second, third, and up to their ninth classes.

Finally, the employee class table can be made just a bit fancier, and you can see exactly how many classes each employee has taken. If columns A and B still contain names and classes, you could place a single instance of each employee name in the first rows of column D, leaving column C blank. In column E you can place the following formula to the right of each employee name:

=COUNTIF(A:A,D2)

The result is that column E contains the number of instances of the name in column D that appears in column A. In other words, you have a count of how many classes each employee has taken. You could then use conditional formatting on the cells in column D so that they are shown in red if the count in column E is 10 or more.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10345) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Counting Employees in Classes.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Modifying Default Year for Dates

When entering dates into a worksheet, you may want the dates to default to last year instead of this year. Here's a way ...

Discover More

Changing Characters on Keyboard Keys

Want to assign some fancy characters to keyboard keys for characters you seldom use? There are a couple of ways you can ...

Discover More

Removing Only One Text Highlighting Color

If you use text highlighting extensively in your documents, you may want to selectively remove some of the colors. This ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (ribbon)

Filling References to Another Workbook

When you create references to cells in other workbooks, Excel, by default, makes the references absolute. This makes it ...

Discover More

Summing When the First Character Matches a Value

Summing data is a common need in Excel. Summing lots of data based on a condition that needs to be met can be a bit more ...

Discover More

Throwing Out the Lowest Score

Want to add up a bunch of scores, without including the lowest one in the bunch? You can make a small change to your ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 8 - 5?

2020-06-29 09:55:20

Allen

Eric,

There is no way to do this of which I'm aware, other than forcing folks to log in to the Tips.Net site. You see, your newsletter subscription is under your e-mail address and any browsing you do at the Tips.Net site is not under that e-mail address; the best we can do is to determine your IP address. IP addresses change all the time, so we cannot tie an IP address to a e-mail address.

That being said, when you see the invite to subscribe, if you click the "close" link in the invite AND you have cookies enabled on your system AND you don't delete those cookies, then you should not see that invite again for about 6 months.

-Allen


2020-06-28 22:13:45

Tom D Santi

Interesting tip. I'm curious why you wouldn't just run a pivot table counting the instances of each name in column A (row would be Name; values would be count of Name). Then sort the pivot table high to low based on the counts of the names.


2020-06-27 11:06:14

Eric Toll

Alan,

I enjoy your Windows, Excel and Word tips each week and have purchased some of your books. I subscribe to the newsletters. When I go to the website to read the details on the tip, after about 15 seconds, the screen is blocked by a popup asking me to subscribe. Since I reached the site with a link from my newsletter subscription, this is very annoying. I have to stop reading midsentence and reach for my mouse or touchpad or phone and close the window.

With all your maco magic, isn't there a way to recognize a subscriber and prevent the window from popping up?

Thanks


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.