Here's one way to do it. Let me know if my sample sheets don't match yours.
The HS Schedules sheet:
Excel 2010
| A | B | C | D | E | F | G | H | I | J | K | L | M | N | O |
---|
| | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | |
aaa | Football | | | | | | | | | | | | | | |
bbb | Golf | | | | | | | | | | | | | | |
ccc | Art | | | | | | | | | | | | | | |
ddd | Chemistry | | | | | | | | | | | | | | |
eee | Golf | | | | | | | | | | | | | | |
fff | Football | | | | | | | | | | | | | | |
ggg | Football | | | | | | | | | | | | | | |
hhh | Golf | | | | | | | | | | | | | | |
iii | Chemistry | | | | | | | | | | | | | | |
<tbody>
[TD="align: center"]1[/TD]
[TD="bgcolor: #FAFAFA"]Student #[/TD]
[TD="bgcolor: #FAFAFA"]LastFirst[/TD]
[TD="bgcolor: #FAFAFA"]Period1[/TD]
[TD="bgcolor: #FAFAFA, align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FAFAFA"]Period 6 Course[/TD]
[TD="bgcolor: #FAFAFA"]Period 6 Teacher[/TD]
[TD="align: center"]2[/TD]
[TD="bgcolor: #FAFAFA, align: right"]123456[/TD]
[TD="bgcolor: #FAFAFA"]lastfirst[/TD]
[TD="bgcolor: #FAFAFA"]2D Art[/TD]
[TD="bgcolor: #FAFAFA, align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FAFAFA"]Football[/TD]
[TD="bgcolor: #FAFAFA"]Doe_John[/TD]
[TD="align: center"]3[/TD]
[TD="align: right"]111[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FAFAFA"]Doe_John[/TD]
[TD="align: center"]4[/TD]
[TD="align: right"]222[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FAFAFA"]Roe_Mary[/TD]
[TD="align: center"]5[/TD]
[TD="align: right"]333[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FAFAFA"]Doe_John[/TD]
[TD="align: center"]6[/TD]
[TD="align: right"]444[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FAFAFA"]Roe_Mary[/TD]
[TD="align: center"]7[/TD]
[TD="align: right"]555[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FAFAFA"]Roe_Mary[/TD]
[TD="align: center"]8[/TD]
[TD="align: right"]666[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FAFAFA"]Doe_John[/TD]
[TD="align: center"]9[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FAFAFA"]Smith_Ann[/TD]
[TD="align: center"]10[/TD]
[TD="align: right"]888[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FAFAFA"]Doe_John[/TD]
[TD="align: center"]11[/TD]
[TD="align: right"]999[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FAFAFA"]Smith_Ann[/TD]
</tbody>
HS Schedules
The teacher sheet:
Excel 2010
| A | B | C | D | E | F | G | H | I | J | K | L | M | N | O |
---|
Football | | | | | | | | | | | | | | | |
Teacher | # of students | Exclude | Course | Students | Teacher | # of students | Excluded | Golf | | | | | | | |
Roe_Mary | Art | Roe_Mary | | | | | | | | | | | | | |
Doe_John | X | Football | Doe_John | | | | | | | | | | | | |
Smith_Ann | X | Golf | Smith_Ann | | | | | | | | | | | | |
Jones_Bob | Physics | Jones_Bob | | | | | | | | | | | | | |
<tbody>
[TD="align: center"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]2[/TD]
[TD="align: center"]2[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]3[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]4[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"][/TD]
[TD="align: right"]4[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]5[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"][/TD]
[TD="align: right"]3[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]6[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
</tbody>
Teacher List
[TABLE="width: 85%"]
<tbody>[TR]
[TD]
Worksheet Formulas[TABLE="width: 100%"]
<tbody>[TR="bgcolor: #DAE7F5"]
[TH]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]J3[/TH]
[TD="align: left"]=B3[/TD]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]O1[/TH]
[TD="align: left"]=COUNTIF(
D1:D500,"X")[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 85%"]
<tbody>[TR]
[TD]
Array Formulas[TABLE="width: 100%"]
<tbody>[TR="bgcolor: #DAE7F5"]
[TH]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]K3[/TH]
[TD="align: left"]{=SUM(
COUNTIFS('HS Schedules'!O:O,I3,'HS Schedules'!N:N,OFFSET('Teacher List'!$N$1,0,0,'Teacher List'!$O$1,1)))}[/TD]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]N1[/TH]
[TD="align: left"]{=IFERROR(
INDEX(E:E,SMALL(IF(D3:D500="X",ROW(D3:D500)),ROW())),"")}[/TD]
[/TR]
</tbody>[/TABLE]
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself[/TD]
[/TR]
</tbody>[/TABLE]
I removed your E1, F1, and H formulas, and replaced them with a list in N. You can put this in H if you want, now that it's available. The N list contains the excluded courses. The O1 cell contains the number of excluded courses. Put the formula in N1, confirm it with Control-Shift-Enter. Then copy the cell and paste it down as far as necessary. Then put in the O1 formula. Then put in the K3 formula, confirm with Control-Shift-Enter, and paste it down the column.
Let me know if this works for you.
Edit: I have heard that the IFERROR function is fairly inefficient, and in a large spreadsheet might slow it down. The N1 formula can be replaced with:
=IF(ROW()<=$O$1,INDEX(E:E,SMALL(IF(D3:D500="X",ROW(D3:D500)),ROW())),"")
and confirm with Control-Shift-Enter. Then use it the same way.