You probably are using that damn Option Explicit.

Add this at the top of the code.

Dim sn, x0,i as long