To get to the bit of code that displays the message, r must be either < 2 or
> lastrow.
What's the value of r?
You can find this out several ways but the best is probably to set a
breakpoint.
Position your cursor on the line
If r > 1 And r <= LastRow Then
And press F9
Or
Single Click in the grey margin to the left of the window at that line.
A red dot should appear and the line should be highlited red.
This indicates that a breakpoint has been set.
Run the application.
The code will pause at the breakpointed line and you can interogate r for
it's value.
If you "hover" over r it's value should be shown.
You can also set a watch on r.
Left click on r and select add watch.
Click OK and a watch window will come up showing the value of r.
BTW....
It's generally better to fully name variables and even better to somehow
indicate their type.
I personally would name r as lnglRowNumber
This would tell me it was a Long, a Local variable and give information
about what it represents.
Likewise, LastRow would become cgLastRow indicating a constant that is
global.
Please do get back if you know the value of r and are still getting stuck.