Did I do something wrong?
I do not think so. If my belief is correct, then you are doing it exactly "right" and most of the rest of us do it "wrong".
Go back to the code window where you pasted Dominic's code (the second time); namely, the code window for the ThisWorkbook object. Do you see this:
near the top of the code window?
If so, and if you did not type it there yourself, then you have set your default properties to ALWAYS add this option to every code window that you use. This is the "right" thing to do. But, Excel does not start out that way. And most of us are too lazy to turn this option "on".
Just for a test, delete the line that says "Option Explicit", and try again.
If that works, then you need to decide if you are going to:
1. turn off this Option, or
2. change Dominic's code by adding Dim statements for every variable used
To turn off this option (and live dangerously, like most of us) do the following:
1. in the VB Editor menu, select Tools >> Options, this opens the Options dialog
2. in the Options dialog, select the "Editor" tab
3. in the section for "Code Settings", click "off" the entry for "Require Variable Declaration"
4. Click "OK"
Bookmarks