How does it freeze at 7K rows when you have 1,668 rows per sheet? Does it run to completion with a smaller data set? It's extremely hard to follow what your code is doing, with that thrice-nested loop, the insufficient indentation, confusing or irrelevant comments and the single-letter variable names - I'd suggest you try to improve the readability first,
and then make changes to improve performance and memory footprint. Otherwise you'll be making changes and very likely introduce bugs. —
Mat's Mug ♦ 1 min ago