The main problem seems to be that you have 2 "If" statements and
no "End If" statements. "If" and "End If" must be in pairs. I can't
tell exactly what you want to do, but you may need "ElseIf"
or "Else".
Highlight your "If" statement and press F1 to see the help on this.
Also, you need to close your "Do" with "Loop".
Other Tips: If you haven't already, try using F8 to step through
your code. It is also very helpful to select "View - Locals Window"
to see all your variables while stepping code. Hovering the cursor
over variables also lets you see their value. These are alternatives
to the message box method.