Please help simplifying this IF statement
<p>I have this IF statement that is doing what I want it to do, but I would like it to have more nested statements and excel won't allow it.</p>

<ul>
<li>In each row I have one course mark for each student, sorted by their ID number.  </li>
<li>Some students have 11 lines of courses and some have 30.  </li>
</ul>

<p>I want a formula that will find the highest course mark for each student, based off of their id, but some students have 30 lines of courses before the next student's courses start so currently I can only read the first 12 lines (courses) for each student.</p>

<p>If anyone has a suggestion I would really appreciate it.</p>

<p>Thanks</p>

<blockquote>
  <p>=IF(A2=D6,IF(A2=D7,IF(A2=D8,IF(A2=D9,IF(A2=D10,IF(A2=D11,IF(A2=D12,LARGE(H2:M12,1),LARGE(H2:M11,1)),LARGE(H2:M10,1)),LARGE(H2:M9,1)),LARGE(H2:M8,1)),LARGE(H2:M7,1)),LARGE(H2:M6,1)),"")</p>
</blockquote>