Simple because, ad mentioned by Tabsoft, you have forgotten to clear the variable 'CounterA' before entering the sorting routine.

Cheers

Al.