Please use meaningful subject lines.
Sort the rows on the first five columns
In the column after the last column used in row 2 if that is the first row of
the matrix put the following (I am assuming CW2) :
=IF((A2=A1)*(B2=B1)*(C2=C1)*(D2=D1)*(E2=E1),CW1+1,1)
Now copy that down the 300 rows
The count will increment until one of the first five cells changes.