Yah, that "End if" error comes up for more things than just the If...Endif commands. Another thing that can trigger it is not having a "WEND" to your "WHILE".
@Graythe: I didn't know that! Thanks for that really useful tip!
@Graythe: I didn't know that! Thanks for that really useful tip!