I'm about to call it a day (1 AM here).
For any error message, please indicate the exact error as popped up by Excel VBA. That will increase the chance to guide you well.
First of all, is it on the first or second line of your code?
I don't get this error here, so it probalby has something to do with the slight changes between your version and the sample.
I have also attached the working example for you to see if this one runs well.
If it does not, there might be another issue (local version, Excel version; settings ...) to be debugged.