Wow!
That's some macro. I don't think it's the case that your macro is running continuously if by that you think it's got stuck in an infinite loop. The macros is certainly running continuously - that's what it's supposed to do. However when you get to the loop
For z = 2 To LR
it's processing over 5000 rows from circa 2157 to 7419. On my reasonably fast laptop the loop is taking 3 seconds so with over 5000 iterations it's going to take over 4 hours.
I can't help thinking that you perhaps need to rethink the code.
For a start try
1. Breaking it down into smallet procedures so that it's more easy to read and control.
2. Don't Activate (or select) cells. Every time you do that there's a time overhead involved in VBA jumping back to the Excel App, and then jumping back. If you're processing large ranges - as here, read them into a VBA array(s) and process them entirely in VBA only writing the final resultant array back to Excel at the end.
3. The fastest way I know of processing stuff like entering values to specific cells (or deleting rows) is to use Data Filtering rather than loop procedures. Whenever you think about creating a loop think first whether there is a better way. A filter is extremely efficient and when you use syntax like
you can update whole blocks of cells instantaneously. So where you are detecting whether F,V,X & L cells contain stuff, and then making column 32 = 40, a filter could do that in one hit.
4. Try and avoid 'spaghetti' code where you jump out of loops (Goto Skip_Me). I don't think that's a particular problem here but one day it will catch you out and it tends to make code hard to read.
Bookmarks