You're getting that error because you're missing the "Loop", like so:
But you don't want to do exactly that, because you're only incrementing your row number in the first DO loop. So you want all of your if statements to be in the same loop. But even that doesn't solve your problem, because think of this:
You delete a row, which shift everything up, then increment your row number by 1, which would then skip over the row that was just shifted up. Example:
- row_number = 2
- row 2 deleted
- row 3 shifted up to become row 2
- Loop
- row_number = 3
- the new shifted up row 2 is never evaluated!
So when deleting rows, it's best to loop through them backwards from bottom to top, thus eliminating the problem highlighted above.
There's some incomplete code here, so I can't say certainly that my modifications will work. For example, you never initialized row_number in the code you provided, so I'm going to guess the data you want evaluated starts in row 2. Also Sheet1 is never defined, so this code won't work unless you've defined it elsewhere.
Try this in replacement starting at your "Do" line and going through the end of the sub. If it doesn't work for you, I'll need to see the full Sub, and an example workbook would be nice.
Bookmarks