Your Option Explicit should be the very first line of the module. It can't
go inside a subroutine or function. However, none of that code should have
been put inside a subroutine or function, so I suspect your copy/paste
missed.
Consider Option Explicit as absolutely essential for VBA development -
particularly if you plan to ask questions on Excel groups - it reduces the
possibility of typos causing obscure problems.
Looks as though "y" was defined but never used.