The solution I provided to you works but does take some time if there are thousands of rows. I just tested it on 5000 rows and it took about 1 minute to complete.