A very minor thing but you could save a little processing by removing that red $
For example, in row 4 of your sample data, the fact that the logical test in your if statement is TRUE, means that there must not be any 8s above row 4 so there is no need to include rows 2 & 3 in the COUNTIF.
Of course the longer the list is and the further down the sheet the formula gets copied, the greater the saving when a new value is found.