Please Note: This article is written for users of the following Microsoft Excel versions: 2007 and 2010. 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: Compiling a List of Students in a Course.
by Allen Wyatt
(last updated December 3, 2018)
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 (12347) applies to Microsoft Excel 2007 and 2010. You can find a version of this tip for the older menu interface of Excel here: Compiling a List of Students in a Course.
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!
When working with names or a different series of words, you may need to pull the initial letters from each word in the ...Discover More
Finding the maximum value in a range of cells is easy; finding the address of the cell containing that value is a ...Discover More
Do you need to reverse a series of integer values, such as 5 becomes 1, 4 becomes 2, etc.? There are several ways you can ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
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.