Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Compiling a List of Students in a Course.

# Compiling a List of Students in a Course

by Allen Wyatt
(last updated September 7, 2017)

Keval has a table of over 5,000 students distributed across 22 courses of study. Against each student's name in each row of this table is indicated the course in which the student is registered. Keval would like, on a different worksheet, to put a course name in cell A1 and then have Excel display, beginning in row 3, all the students in that course, as pulled from the list. He wonders if there is a way to do this with a formula.

The best solution to this problem is going to be dependent, in large part, on how your source data is organized. If you only have two columns (student name and course name), then it is possible that you don't even need to use a second worksheet. Instead, you can get by using Excel's filtering capabilities. Just filter on the contents of the column that contains the course name, and you can easily limit what is displayed to only those students in the course.

If you must have the information appear on the second worksheet, it may be best to use an array formula to extract the students. Put the desired course in cell A1 and then the following formula in cell A3:

```=IF(COUNTIF(Sheet1!\$B\$1:\$B\$5000,\$A\$1)<ROW()-2,"",
INDEX(Sheet1!\$A\$1:\$A\$5000,SMALL(IF(Sheet1!\$B\$1:\$B\$5000=\$A\$1,
ROW(Sheet1!\$B\$1:\$B\$5000)),ROW()-2)))
```

Remember—this is a single formula and you need to enter it in the cell by pressing Ctrl+Shift+Enter. Copy the formula downward into enough cells that it should accommodate your largest class. The formula also assumes that the source data in in rows 1 through 5000; if this is not the case, you'll want to modify the formula to reflect the appropriate range.

Another approach is to create a PivotTable based upon the student/course list. All you need to do is make sure that both the course name and the student name fields are in the "row" area of the PivotTable. Put the course name field first and the student name field second, and you'll end up with a list of all courses with the students under each course name.

If your source data has additional information associated with it (such as grades, addresses, book assignments, etc.), then you may want to consider working with an actual database program, such as Access. You'll be able to manipulate and extract data using tools that are superior to those in Excel.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12346) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Compiling a List of Students in a Course.

##### 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

Turning Off Line Numbering

Need to have line numbering turned off for a paragraph or two? You can accomplish the task by following these steps.

Discover More

Dealing with Oily Skin

Does your skin feel greasy to the touch and are you having problems getting just the right look with your facial makeup? ...

Discover More

Automatically Identifying Repeated Words

Need to find out how many times words are repeated in a document? If so, you'll appreciate the discussion in this tip ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

Counting Jobs Completed On a Date

When you store the date and time in a single cell, it can be a bit confusing to count how many cells contain a particular ...

Discover More

Extracting First and Last Words

When working with text phrases stored in cells, it might be helpful to be able to extract words from the phrase. In this ...

Discover More

Evaluating Formulas

Need a bit of help in figuring out how Excel is evaluating a particular formula? It's easy to figure out if you use the ...

Discover More
##### Subscribe

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

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}] 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 five minus 0?

2012-12-08 05:55:59

Michael Avidan - MVP

The above Comment refers to "Excel 2007" and above.

In Excel "97-2003" The formula will be:

=IF(SUM((B\$1:W\$1=Y\$1)*(B\$2:W\$11="x"))<ROW()-2,"",INDEX(A:A,SMALL(IF((B\$1:W\$1=Y\$1)*(B\$2:W\$11="x"),ROW(B\$2:W\$11)),ROW()-2)))

Michael Avidan
“Microsoft®” MVP – Excel
ISRAEL

2012-12-08 05:26:34

Michael Avidan - MVP

1) The picture, in the following link, is the solution as I see it to Keval Aroras original question who stated:
"I have a table of over 5,000 students distributed across 22 courses of study".

2) Excel 2007/10/13 have a new function: IFERROR which eliminates the need of the long test:
IF(COUNTIF(Sheet1!\$B\$1:\$B\$5000,\$A\$1)<ROW()-2

http://ipic.se/img/1354962018.png

Michael Avidan
“Microsoft®” MVP – Excel
ISRAEL

##### This Site

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