Detect and mark all duplicates in the same loop
I had a loop where an array with possible duplicates of 'code'. Did not want to loop the array twice and didn't want to extend the array with yet another item for each row. So I made this script keep track of the first occurrence of each 'code' and any duplicate 'code', and if a duplicate is found the script marks the first occurrence as number 1 and then mark up any additional duplicate with 2, 3, 4and so on.